From 677890fc087775a66037b11fba626acb9d2a8ef1 Mon Sep 17 00:00:00 2001 From: Christophe Jolif Date: Thu, 17 Mar 2016 22:44:21 +0100 Subject: [PATCH] Generates Int32/Int64 for Swift when those are the required formats. Fixes #2133. --- .../codegen/languages/SwiftCodegen.java | 10 +- .../src/main/resources/swift/Models.mustache | 6 + .../src/main/resources/swift/model.mustache | 6 +- .../Classes/Swaggers/APIs/PetAPI.swift | 248 +++++++++--------- .../Classes/Swaggers/APIs/StoreAPI.swift | 116 ++++---- .../Classes/Swaggers/APIs/UserAPI.swift | 8 +- .../Classes/Swaggers/Models.swift | 42 +-- .../Classes/Swaggers/Models/Category.swift | 4 +- .../Swaggers/Models/InlineResponse200.swift | 18 +- .../Swaggers/Models/Model200Response.swift | 4 +- .../Classes/Swaggers/Models/ModelReturn.swift | 4 +- .../Classes/Swaggers/Models/Name.swift | 8 +- .../Classes/Swaggers/Models/Order.swift | 12 +- .../Classes/Swaggers/Models/Pet.swift | 4 +- .../Swaggers/Models/SpecialModelName.swift | 4 +- .../Classes/Swaggers/Models/Tag.swift | 4 +- .../Classes/Swaggers/Models/User.swift | 8 +- 17 files changed, 261 insertions(+), 245 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java index 003dbba2b79..0725d36eec8 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java @@ -74,6 +74,8 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig { languageSpecificPrimitives = new HashSet( Arrays.asList( "Int", + "Int32", + "Int64", "Float", "Double", "Bool", @@ -115,10 +117,10 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig { typeMapping.put("string", "String"); typeMapping.put("char", "Character"); typeMapping.put("short", "Int"); - typeMapping.put("int", "Int"); - typeMapping.put("long", "Int"); - typeMapping.put("integer", "Int"); - typeMapping.put("Integer", "Int"); + typeMapping.put("int", "Int32"); + typeMapping.put("long", "Int64"); + typeMapping.put("integer", "Int32"); + typeMapping.put("Integer", "Int32"); typeMapping.put("float", "Float"); typeMapping.put("number", "Double"); typeMapping.put("double", "Double"); diff --git a/modules/swagger-codegen/src/main/resources/swift/Models.mustache b/modules/swagger-codegen/src/main/resources/swift/Models.mustache index d3090faf2a0..31cb4a2e219 100644 --- a/modules/swagger-codegen/src/main/resources/swift/Models.mustache +++ b/modules/swagger-codegen/src/main/resources/swift/Models.mustache @@ -56,6 +56,12 @@ class Decoders { static func decode(clazz clazz: T.Type, source: AnyObject) -> T { initialize() + if T.self is Int32.Type && source is NSNumber { + return source.intValue as! T; + } + if T.self is Int64.Type && source is NSNumber { + return source.longLongValue as! T; + } if source is T { return source as! T } diff --git a/modules/swagger-codegen/src/main/resources/swift/model.mustache b/modules/swagger-codegen/src/main/resources/swift/model.mustache index f095940a0c1..b8b31e9a7df 100644 --- a/modules/swagger-codegen/src/main/resources/swift/model.mustache +++ b/modules/swagger-codegen/src/main/resources/swift/model.mustache @@ -25,8 +25,10 @@ public class {{classname}}: JSONEncodable { // MARK: JSONEncodable func encodeToJSON() -> AnyObject { - var nillableDictionary = [String:AnyObject?](){{#vars}}{{#isNotContainer}}{{#isPrimitiveType}}{{^isEnum}} - nillableDictionary["{{baseName}}"] = self.{{name}}{{/isEnum}}{{/isPrimitiveType}}{{#isEnum}} + var nillableDictionary = [String:AnyObject?](){{#vars}}{{#isNotContainer}}{{#isPrimitiveType}}{{^isEnum}}{{#isInteger}}{{^isLong}} + nillableDictionary["{{baseName}}"] = self.{{name}} != nil ? NSNumber(int: self.{{name}}!) : nil{{/isLong}}{{/isInteger}}{{^isInteger}}{{#isLong}} + nillableDictionary["{{baseName}}"] = self.{{name}} != nil ? NSNumber(longLong: self.{{name}}!) : nil{{/isLong}}{{/isInteger}}{{^isInteger}}{{^isLong}} + nillableDictionary["{{baseName}}"] = self.{{name}}{{/isLong}}{{/isInteger}}{{/isEnum}}{{/isPrimitiveType}}{{#isEnum}} nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.rawValue{{/isEnum}}{{^isPrimitiveType}} nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.encodeToJSON(){{/isPrimitiveType}}{{/isNotContainer}}{{#isContainer}} nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.encodeToJSON(){{/isContainer}}{{/vars}} diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift index ddb328e8ee5..a76f0352f52 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift @@ -132,7 +132,7 @@ public class PetAPI: APIBase { - parameter petId: (path) Pet id to delete - parameter completion: completion handler to receive the data and the error objects */ - public class func deletePet(petId petId: Int, completion: ((error: ErrorType?) -> Void)) { + public class func deletePet(petId petId: Int64, completion: ((error: ErrorType?) -> Void)) { deletePetWithRequestBuilder(petId: petId).execute { (response, error) -> Void in completion(error: error); } @@ -145,7 +145,7 @@ public class PetAPI: APIBase { - parameter petId: (path) Pet id to delete - returns: Promise */ - public class func deletePet(petId petId: Int) -> Promise { + public class func deletePet(petId petId: Int64) -> Promise { let deferred = Promise.pendingPromise() deletePet(petId: petId) { error in if let error = error { @@ -171,7 +171,7 @@ public class PetAPI: APIBase { - returns: RequestBuilder */ - public class func deletePetWithRequestBuilder(petId petId: Int) -> RequestBuilder { + public class func deletePetWithRequestBuilder(petId petId: Int64) -> RequestBuilder { var path = "/pet/{petId}" path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil) let URLString = PetstoreClientAPI.basePath + path @@ -225,20 +225,20 @@ public class PetAPI: APIBase { - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{example=[ { - "tags" : [ { - "id" : 123456789, - "name" : "aeiou" - } ], + - examples: [{contentType=application/json, example=[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 123456789, "category" : { - "id" : 123456789, - "name" : "aeiou" + "name" : "aeiou", + "id" : 123456789 }, - "status" : "aeiou", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -} ], contentType=application/json}, {example= + "tags" : [ { + "name" : "aeiou", + "id" : 123456789 + } ], + "status" : "aeiou" +} ]}, {contentType=application/xml, example= 123456 doggie @@ -247,21 +247,21 @@ public class PetAPI: APIBase { string -, contentType=application/xml}] - - examples: [{example=[ { - "tags" : [ { - "id" : 123456789, - "name" : "aeiou" - } ], +}] + - examples: [{contentType=application/json, example=[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 123456789, "category" : { - "id" : 123456789, - "name" : "aeiou" + "name" : "aeiou", + "id" : 123456789 }, - "status" : "aeiou", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -} ], contentType=application/json}, {example= + "tags" : [ { + "name" : "aeiou", + "id" : 123456789 + } ], + "status" : "aeiou" +} ]}, {contentType=application/xml, example= 123456 doggie @@ -270,7 +270,7 @@ public class PetAPI: APIBase { string -, contentType=application/xml}] +}] - parameter status: (query) Status values that need to be considered for query (optional, default to available) @@ -331,20 +331,20 @@ public class PetAPI: APIBase { - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{example=[ { - "tags" : [ { - "id" : 123456789, - "name" : "aeiou" - } ], + - examples: [{contentType=application/json, example=[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 123456789, "category" : { - "id" : 123456789, - "name" : "aeiou" + "name" : "aeiou", + "id" : 123456789 }, - "status" : "aeiou", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -} ], contentType=application/json}, {example= + "tags" : [ { + "name" : "aeiou", + "id" : 123456789 + } ], + "status" : "aeiou" +} ]}, {contentType=application/xml, example= 123456 doggie @@ -353,21 +353,21 @@ public class PetAPI: APIBase { string -, contentType=application/xml}] - - examples: [{example=[ { - "tags" : [ { - "id" : 123456789, - "name" : "aeiou" - } ], +}] + - examples: [{contentType=application/json, example=[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 123456789, "category" : { - "id" : 123456789, - "name" : "aeiou" + "name" : "aeiou", + "id" : 123456789 }, - "status" : "aeiou", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -} ], contentType=application/json}, {example= + "tags" : [ { + "name" : "aeiou", + "id" : 123456789 + } ], + "status" : "aeiou" +} ]}, {contentType=application/xml, example= 123456 doggie @@ -376,7 +376,7 @@ public class PetAPI: APIBase { string -, contentType=application/xml}] +}] - parameter tags: (query) Tags to filter by (optional) @@ -403,7 +403,7 @@ public class PetAPI: APIBase { - parameter petId: (path) ID of pet that needs to be fetched - parameter completion: completion handler to receive the data and the error objects */ - public class func getPetById(petId petId: Int, completion: ((data: Pet?, error: ErrorType?) -> Void)) { + public class func getPetById(petId petId: Int64, completion: ((data: Pet?, error: ErrorType?) -> Void)) { getPetByIdWithRequestBuilder(petId: petId).execute { (response, error) -> Void in completion(data: response?.body, error: error); } @@ -416,7 +416,7 @@ public class PetAPI: APIBase { - parameter petId: (path) ID of pet that needs to be fetched - returns: Promise */ - public class func getPetById(petId petId: Int) -> Promise { + public class func getPetById(petId petId: Int64) -> Promise { let deferred = Promise.pendingPromise() getPetById(petId: petId) { data, error in if let error = error { @@ -434,26 +434,26 @@ public class PetAPI: APIBase { - GET /pet/{petId} - Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - - API Key: - - type: apiKey api_key - - name: api_key - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{example={ - "tags" : [ { - "id" : 123456789, - "name" : "aeiou" - } ], + - API Key: + - type: apiKey api_key + - name: api_key + - examples: [{contentType=application/json, example={ + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 123456789, "category" : { - "id" : 123456789, - "name" : "aeiou" + "name" : "aeiou", + "id" : 123456789 }, - "status" : "aeiou", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -}, contentType=application/json}, {example= + "tags" : [ { + "name" : "aeiou", + "id" : 123456789 + } ], + "status" : "aeiou" +}}, {contentType=application/xml, example= 123456 doggie @@ -462,21 +462,21 @@ public class PetAPI: APIBase { string -, contentType=application/xml}] - - examples: [{example={ - "tags" : [ { - "id" : 123456789, - "name" : "aeiou" - } ], +}] + - examples: [{contentType=application/json, example={ + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 123456789, "category" : { - "id" : 123456789, - "name" : "aeiou" + "name" : "aeiou", + "id" : 123456789 }, - "status" : "aeiou", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -}, contentType=application/json}, {example= + "tags" : [ { + "name" : "aeiou", + "id" : 123456789 + } ], + "status" : "aeiou" +}}, {contentType=application/xml, example= 123456 doggie @@ -485,13 +485,13 @@ public class PetAPI: APIBase { string -, contentType=application/xml}] +}] - parameter petId: (path) ID of pet that needs to be fetched - returns: RequestBuilder */ - public class func getPetByIdWithRequestBuilder(petId petId: Int) -> RequestBuilder { + public class func getPetByIdWithRequestBuilder(petId petId: Int64) -> RequestBuilder { var path = "/pet/{petId}" path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil) let URLString = PetstoreClientAPI.basePath + path @@ -511,7 +511,7 @@ public class PetAPI: APIBase { - parameter petId: (path) ID of pet that needs to be fetched - parameter completion: completion handler to receive the data and the error objects */ - public class func getPetByIdInObject(petId petId: Int, completion: ((data: InlineResponse200?, error: ErrorType?) -> Void)) { + public class func getPetByIdInObject(petId petId: Int64, completion: ((data: InlineResponse200?, error: ErrorType?) -> Void)) { getPetByIdInObjectWithRequestBuilder(petId: petId).execute { (response, error) -> Void in completion(data: response?.body, error: error); } @@ -524,7 +524,7 @@ public class PetAPI: APIBase { - parameter petId: (path) ID of pet that needs to be fetched - returns: Promise */ - public class func getPetByIdInObject(petId petId: Int) -> Promise { + public class func getPetByIdInObject(petId petId: Int64) -> Promise { let deferred = Promise.pendingPromise() getPetByIdInObject(petId: petId) { data, error in if let error = error { @@ -542,52 +542,52 @@ public class PetAPI: APIBase { - GET /pet/{petId}?response=inline_arbitrary_object - Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - - API Key: - - type: apiKey api_key - - name: api_key - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{example={ - "id" : 123456789, - "tags" : [ { - "id" : 123456789, - "name" : "aeiou" - } ], - "category" : "{}", - "status" : "aeiou", + - API Key: + - type: apiKey api_key + - name: api_key + - examples: [{contentType=application/json, example={ + "photoUrls" : [ "aeiou" ], "name" : "doggie", - "photoUrls" : [ "aeiou" ] -}, contentType=application/json}, {example= + "id" : 123456789, + "category" : "{}", + "tags" : [ { + "name" : "aeiou", + "id" : 123456789 + } ], + "status" : "aeiou" +}}, {contentType=application/xml, example= + string + doggie 123456 not implemented io.swagger.models.properties.ObjectProperty@37ff6855 string - doggie - string -, contentType=application/xml}] - - examples: [{example={ - "id" : 123456789, - "tags" : [ { - "id" : 123456789, - "name" : "aeiou" - } ], - "category" : "{}", - "status" : "aeiou", +}] + - examples: [{contentType=application/json, example={ + "photoUrls" : [ "aeiou" ], "name" : "doggie", - "photoUrls" : [ "aeiou" ] -}, contentType=application/json}, {example= + "id" : 123456789, + "category" : "{}", + "tags" : [ { + "name" : "aeiou", + "id" : 123456789 + } ], + "status" : "aeiou" +}}, {contentType=application/xml, example= + string + doggie 123456 not implemented io.swagger.models.properties.ObjectProperty@37ff6855 string - doggie - string -, contentType=application/xml}] +}] - parameter petId: (path) ID of pet that needs to be fetched - returns: RequestBuilder */ - public class func getPetByIdInObjectWithRequestBuilder(petId petId: Int) -> RequestBuilder { + public class func getPetByIdInObjectWithRequestBuilder(petId petId: Int64) -> RequestBuilder { var path = "/pet/{petId}?response=inline_arbitrary_object" path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil) let URLString = PetstoreClientAPI.basePath + path @@ -607,7 +607,7 @@ public class PetAPI: APIBase { - parameter petId: (path) ID of pet that needs to be fetched - parameter completion: completion handler to receive the data and the error objects */ - public class func petPetIdtestingByteArraytrueGet(petId petId: Int, completion: ((data: String?, error: ErrorType?) -> Void)) { + public class func petPetIdtestingByteArraytrueGet(petId petId: Int64, completion: ((data: String?, error: ErrorType?) -> Void)) { petPetIdtestingByteArraytrueGetWithRequestBuilder(petId: petId).execute { (response, error) -> Void in completion(data: response?.body, error: error); } @@ -620,7 +620,7 @@ public class PetAPI: APIBase { - parameter petId: (path) ID of pet that needs to be fetched - returns: Promise */ - public class func petPetIdtestingByteArraytrueGet(petId petId: Int) -> Promise { + public class func petPetIdtestingByteArraytrueGet(petId petId: Int64) -> Promise { let deferred = Promise.pendingPromise() petPetIdtestingByteArraytrueGet(petId: petId) { data, error in if let error = error { @@ -638,20 +638,20 @@ public class PetAPI: APIBase { - GET /pet/{petId}?testing_byte_array=true - Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - - API Key: - - type: apiKey api_key - - name: api_key - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{example="", contentType=application/json}, {example=not implemented io.swagger.models.properties.BinaryProperty@55e6ae9e, contentType=application/xml}] - - examples: [{example="", contentType=application/json}, {example=not implemented io.swagger.models.properties.BinaryProperty@55e6ae9e, contentType=application/xml}] + - API Key: + - type: apiKey api_key + - name: api_key + - examples: [{contentType=application/json, example=""}, {contentType=application/xml, example=not implemented io.swagger.models.properties.BinaryProperty@55e6ae9e}] + - examples: [{contentType=application/json, example=""}, {contentType=application/xml, example=not implemented io.swagger.models.properties.BinaryProperty@55e6ae9e}] - parameter petId: (path) ID of pet that needs to be fetched - returns: RequestBuilder */ - public class func petPetIdtestingByteArraytrueGetWithRequestBuilder(petId petId: Int) -> RequestBuilder { + public class func petPetIdtestingByteArraytrueGetWithRequestBuilder(petId petId: Int64) -> RequestBuilder { var path = "/pet/{petId}?testing_byte_array=true" path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil) let URLString = PetstoreClientAPI.basePath + path @@ -798,7 +798,7 @@ public class PetAPI: APIBase { - parameter _file: (form) file to upload (optional) - parameter completion: completion handler to receive the data and the error objects */ - public class func uploadFile(petId petId: Int, additionalMetadata: String?, _file: NSURL?, completion: ((error: ErrorType?) -> Void)) { + public class func uploadFile(petId petId: Int64, additionalMetadata: String?, _file: NSURL?, completion: ((error: ErrorType?) -> Void)) { uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, _file: _file).execute { (response, error) -> Void in completion(error: error); } @@ -813,7 +813,7 @@ public class PetAPI: APIBase { - parameter _file: (form) file to upload (optional) - returns: Promise */ - public class func uploadFile(petId petId: Int, additionalMetadata: String?, _file: NSURL?) -> Promise { + public class func uploadFile(petId petId: Int64, additionalMetadata: String?, _file: NSURL?) -> Promise { let deferred = Promise.pendingPromise() uploadFile(petId: petId, additionalMetadata: additionalMetadata, _file: _file) { error in if let error = error { @@ -841,7 +841,7 @@ public class PetAPI: APIBase { - returns: RequestBuilder */ - public class func uploadFileWithRequestBuilder(petId petId: Int, additionalMetadata: String?, _file: NSURL?) -> RequestBuilder { + public class func uploadFileWithRequestBuilder(petId petId: Int64, additionalMetadata: String?, _file: NSURL?) -> RequestBuilder { var path = "/pet/{petId}/uploadImage" path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil) let URLString = PetstoreClientAPI.basePath + path diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift index 09390bc4728..82d8ff179e5 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift @@ -111,36 +111,36 @@ public class StoreAPI: APIBase { - API Key: - type: apiKey x-test_api_client_secret - name: test_api_client_secret - - examples: [{example=[ { - "id" : 123456789, + - examples: [{contentType=application/json, example=[ { "petId" : 123456789, - "complete" : true, - "status" : "aeiou", "quantity" : 123, - "shipDate" : "2000-01-23T04:56:07.000+0000" -} ], contentType=application/json}, {example= + "id" : 123456789, + "shipDate" : "2000-01-23T04:56:07.000+0000", + "complete" : true, + "status" : "aeiou" +} ]}, {contentType=application/xml, example= 123456 123456 0 2000-01-23T04:56:07.000Z string true -, contentType=application/xml}] - - examples: [{example=[ { - "id" : 123456789, +}] + - examples: [{contentType=application/json, example=[ { "petId" : 123456789, - "complete" : true, - "status" : "aeiou", "quantity" : 123, - "shipDate" : "2000-01-23T04:56:07.000+0000" -} ], contentType=application/json}, {example= + "id" : 123456789, + "shipDate" : "2000-01-23T04:56:07.000+0000", + "complete" : true, + "status" : "aeiou" +} ]}, {contentType=application/xml, example= 123456 123456 0 2000-01-23T04:56:07.000Z string true -, contentType=application/xml}] +}] - parameter status: (query) Status value that needs to be considered for query (optional, default to placed) @@ -166,7 +166,7 @@ public class StoreAPI: APIBase { - parameter completion: completion handler to receive the data and the error objects */ - public class func getInventory(completion: ((data: [String:Int]?, error: ErrorType?) -> Void)) { + public class func getInventory(completion: ((data: [String:Int32]?, error: ErrorType?) -> Void)) { getInventoryWithRequestBuilder().execute { (response, error) -> Void in completion(data: response?.body, error: error); } @@ -176,10 +176,10 @@ public class StoreAPI: APIBase { Returns pet inventories by status - - returns: Promise<[String:Int]> + - returns: Promise<[String:Int32]> */ - public class func getInventory() -> Promise<[String:Int]> { - let deferred = Promise<[String:Int]>.pendingPromise() + public class func getInventory() -> Promise<[String:Int32]> { + let deferred = Promise<[String:Int32]>.pendingPromise() getInventory() { data, error in if let error = error { deferred.reject(error) @@ -199,23 +199,23 @@ public class StoreAPI: APIBase { - API Key: - type: apiKey api_key - name: api_key - - examples: [{example={ + - examples: [{contentType=application/json, example={ "key" : 123 -}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}] - - examples: [{example={ +}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}] + - examples: [{contentType=application/json, example={ "key" : 123 -}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}] +}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}] - - returns: RequestBuilder<[String:Int]> + - returns: RequestBuilder<[String:Int32]> */ - public class func getInventoryWithRequestBuilder() -> RequestBuilder<[String:Int]> { + public class func getInventoryWithRequestBuilder() -> RequestBuilder<[String:Int32]> { let path = "/store/inventory" let URLString = PetstoreClientAPI.basePath + path let nillableParameters: [String:AnyObject?] = [:] let parameters = APIHelper.rejectNil(nillableParameters) - let requestBuilder: RequestBuilder<[String:Int]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + let requestBuilder: RequestBuilder<[String:Int32]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: true) } @@ -259,8 +259,8 @@ public class StoreAPI: APIBase { - API Key: - type: apiKey api_key - name: api_key - - examples: [{example="{}", contentType=application/json}, {example=not implemented io.swagger.models.properties.ObjectProperty@37aadb4f, contentType=application/xml}] - - examples: [{example="{}", contentType=application/json}, {example=not implemented io.swagger.models.properties.ObjectProperty@37aadb4f, contentType=application/xml}] + - examples: [{contentType=application/json, example="{}"}, {contentType=application/xml, example=not implemented io.swagger.models.properties.ObjectProperty@37aadb4f}] + - examples: [{contentType=application/json, example="{}"}, {contentType=application/xml, example=not implemented io.swagger.models.properties.ObjectProperty@37aadb4f}] - returns: RequestBuilder */ @@ -314,42 +314,42 @@ public class StoreAPI: APIBase { - GET /store/order/{orderId} - For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - - API Key: - - type: apiKey test_api_key_header - - name: test_api_key_header - API Key: - type: apiKey test_api_key_query (QUERY) - name: test_api_key_query - - examples: [{example={ - "id" : 123456789, + - API Key: + - type: apiKey test_api_key_header + - name: test_api_key_header + - examples: [{contentType=application/json, example={ "petId" : 123456789, - "complete" : true, - "status" : "aeiou", "quantity" : 123, - "shipDate" : "2000-01-23T04:56:07.000+0000" -}, contentType=application/json}, {example= + "id" : 123456789, + "shipDate" : "2000-01-23T04:56:07.000+0000", + "complete" : true, + "status" : "aeiou" +}}, {contentType=application/xml, example= 123456 123456 0 2000-01-23T04:56:07.000Z string true -, contentType=application/xml}] - - examples: [{example={ - "id" : 123456789, +}] + - examples: [{contentType=application/json, example={ "petId" : 123456789, - "complete" : true, - "status" : "aeiou", "quantity" : 123, - "shipDate" : "2000-01-23T04:56:07.000+0000" -}, contentType=application/json}, {example= + "id" : 123456789, + "shipDate" : "2000-01-23T04:56:07.000+0000", + "complete" : true, + "status" : "aeiou" +}}, {contentType=application/xml, example= 123456 123456 0 2000-01-23T04:56:07.000Z string true -, contentType=application/xml}] +}] - parameter orderId: (path) ID of pet that needs to be fetched @@ -412,36 +412,36 @@ public class StoreAPI: APIBase { - API Key: - type: apiKey x-test_api_client_secret - name: test_api_client_secret - - examples: [{example={ - "id" : 123456789, + - examples: [{contentType=application/json, example={ "petId" : 123456789, - "complete" : true, - "status" : "aeiou", "quantity" : 123, - "shipDate" : "2000-01-23T04:56:07.000+0000" -}, contentType=application/json}, {example= + "id" : 123456789, + "shipDate" : "2000-01-23T04:56:07.000+0000", + "complete" : true, + "status" : "aeiou" +}}, {contentType=application/xml, example= 123456 123456 0 2000-01-23T04:56:07.000Z string true -, contentType=application/xml}] - - examples: [{example={ - "id" : 123456789, +}] + - examples: [{contentType=application/json, example={ "petId" : 123456789, - "complete" : true, - "status" : "aeiou", "quantity" : 123, - "shipDate" : "2000-01-23T04:56:07.000+0000" -}, contentType=application/json}, {example= + "id" : 123456789, + "shipDate" : "2000-01-23T04:56:07.000+0000", + "complete" : true, + "status" : "aeiou" +}}, {contentType=application/xml, example= 123456 123456 0 2000-01-23T04:56:07.000Z string true -, contentType=application/xml}] +}] - parameter body: (body) order placed for purchasing the pet (optional) diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift index 3f1d18dffb0..ec73c765ac1 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift @@ -270,7 +270,7 @@ public class UserAPI: APIBase { - GET /user/{username} - - - examples: [{example={ + - examples: [{contentType=application/json, example={ "id" : 1, "username" : "johnp", "firstName" : "John", @@ -279,7 +279,7 @@ public class UserAPI: APIBase { "password" : "-secret-", "phone" : "0123456789", "userStatus" : 0 -}, contentType=application/json}] +}}] - parameter username: (path) The name that needs to be fetched. Use user1 for testing. @@ -338,8 +338,8 @@ public class UserAPI: APIBase { - GET /user/login - - - examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}] - - examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}] + - examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}] + - examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}] - parameter username: (query) The user name for login (optional) - parameter password: (query) The password for login in clear text (optional) diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models.swift index 3c62d5fa4c2..329eb295157 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models.swift @@ -56,6 +56,12 @@ class Decoders { static func decode(clazz clazz: T.Type, source: AnyObject) -> T { initialize() + if T.self is Int32.Type && source is NSNumber { + return source.intValue as! T; + } + if T.self is Int64.Type && source is NSNumber { + return source.longLongValue as! T; + } if source is T { return source as! T } @@ -132,7 +138,7 @@ class Decoders { Decoders.addDecoder(clazz: Category.self) { (source: AnyObject) -> Category in let sourceDictionary = source as! [NSObject:AnyObject] let instance = Category() - instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"]) + instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"]) instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"]) return instance } @@ -146,12 +152,12 @@ class Decoders { Decoders.addDecoder(clazz: InlineResponse200.self) { (source: AnyObject) -> InlineResponse200 in let sourceDictionary = source as! [NSObject:AnyObject] let instance = InlineResponse200() - instance.tags = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["tags"]) - instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"]) - instance.category = Decoders.decodeOptional(clazz: AnyObject.self, source: sourceDictionary["category"]) - instance.status = InlineResponse200.Status(rawValue: (sourceDictionary["status"] as? String) ?? "") - instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"]) instance.photoUrls = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["photoUrls"]) + instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"]) + instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"]) + instance.category = Decoders.decodeOptional(clazz: AnyObject.self, source: sourceDictionary["category"]) + instance.tags = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["tags"]) + instance.status = InlineResponse200.Status(rawValue: (sourceDictionary["status"] as? String) ?? "") return instance } @@ -164,7 +170,7 @@ class Decoders { Decoders.addDecoder(clazz: Model200Response.self) { (source: AnyObject) -> Model200Response in let sourceDictionary = source as! [NSObject:AnyObject] let instance = Model200Response() - instance.name = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["name"]) + instance.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"]) return instance } @@ -177,7 +183,7 @@ class Decoders { Decoders.addDecoder(clazz: ModelReturn.self) { (source: AnyObject) -> ModelReturn in let sourceDictionary = source as! [NSObject:AnyObject] let instance = ModelReturn() - instance._return = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["return"]) + instance._return = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["return"]) return instance } @@ -190,8 +196,8 @@ class Decoders { Decoders.addDecoder(clazz: Name.self) { (source: AnyObject) -> Name in let sourceDictionary = source as! [NSObject:AnyObject] let instance = Name() - instance.name = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["name"]) - instance.snakeCase = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["snake_case"]) + instance.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"]) + instance.snakeCase = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["snake_case"]) return instance } @@ -204,9 +210,9 @@ class Decoders { Decoders.addDecoder(clazz: Order.self) { (source: AnyObject) -> Order in let sourceDictionary = source as! [NSObject:AnyObject] let instance = Order() - instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"]) - instance.petId = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["petId"]) - instance.quantity = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["quantity"]) + instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"]) + instance.petId = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["petId"]) + instance.quantity = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["quantity"]) instance.shipDate = Decoders.decodeOptional(clazz: NSDate.self, source: sourceDictionary["shipDate"]) instance.status = Order.Status(rawValue: (sourceDictionary["status"] as? String) ?? "") instance.complete = Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["complete"]) @@ -222,7 +228,7 @@ class Decoders { Decoders.addDecoder(clazz: Pet.self) { (source: AnyObject) -> Pet in let sourceDictionary = source as! [NSObject:AnyObject] let instance = Pet() - instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"]) + instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"]) instance.category = Decoders.decodeOptional(clazz: Category.self, source: sourceDictionary["category"]) instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"]) instance.photoUrls = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["photoUrls"]) @@ -240,7 +246,7 @@ class Decoders { Decoders.addDecoder(clazz: SpecialModelName.self) { (source: AnyObject) -> SpecialModelName in let sourceDictionary = source as! [NSObject:AnyObject] let instance = SpecialModelName() - instance.specialPropertyName = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["$special[property.name]"]) + instance.specialPropertyName = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["$special[property.name]"]) return instance } @@ -253,7 +259,7 @@ class Decoders { Decoders.addDecoder(clazz: Tag.self) { (source: AnyObject) -> Tag in let sourceDictionary = source as! [NSObject:AnyObject] let instance = Tag() - instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"]) + instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"]) instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"]) return instance } @@ -267,14 +273,14 @@ class Decoders { Decoders.addDecoder(clazz: User.self) { (source: AnyObject) -> User in let sourceDictionary = source as! [NSObject:AnyObject] let instance = User() - instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"]) + instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"]) instance.username = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["username"]) instance.firstName = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["firstName"]) instance.lastName = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["lastName"]) instance.email = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["email"]) instance.password = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["password"]) instance.phone = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["phone"]) - instance.userStatus = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["userStatus"]) + instance.userStatus = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["userStatus"]) return instance } diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Category.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Category.swift index f542ea676f8..f844340561f 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Category.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Category.swift @@ -10,7 +10,7 @@ import Foundation public class Category: JSONEncodable { - public var id: Int? + public var id: Int64? public var name: String? @@ -19,7 +19,7 @@ public class Category: JSONEncodable { // MARK: JSONEncodable func encodeToJSON() -> AnyObject { var nillableDictionary = [String:AnyObject?]() - nillableDictionary["id"] = self.id + nillableDictionary["id"] = self.id != nil ? NSNumber(longLong: self.id!) : nil nillableDictionary["name"] = self.name let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] return dictionary diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/InlineResponse200.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/InlineResponse200.swift index 5835a8d9899..2d17cc4af8c 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/InlineResponse200.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/InlineResponse200.swift @@ -16,13 +16,13 @@ public class InlineResponse200: JSONEncodable { case Sold = "sold" } - public var tags: [Tag]? - public var id: Int? + public var photoUrls: [String]? + public var name: String? + public var id: Int64? public var category: AnyObject? + public var tags: [Tag]? /** pet status in the store */ public var status: Status? - public var name: String? - public var photoUrls: [String]? public init() {} @@ -30,12 +30,12 @@ public class InlineResponse200: JSONEncodable { // MARK: JSONEncodable func encodeToJSON() -> AnyObject { var nillableDictionary = [String:AnyObject?]() - nillableDictionary["tags"] = self.tags?.encodeToJSON() - nillableDictionary["id"] = self.id - nillableDictionary["category"] = self.category - nillableDictionary["status"] = self.status?.rawValue - nillableDictionary["name"] = self.name nillableDictionary["photoUrls"] = self.photoUrls?.encodeToJSON() + nillableDictionary["name"] = self.name + nillableDictionary["id"] = self.id != nil ? NSNumber(longLong: self.id!) : nil + nillableDictionary["category"] = self.category + nillableDictionary["tags"] = self.tags?.encodeToJSON() + nillableDictionary["status"] = self.status?.rawValue let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] return dictionary } diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Model200Response.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Model200Response.swift index 69b18379b28..01d8e078579 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Model200Response.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Model200Response.swift @@ -10,7 +10,7 @@ import Foundation public class Model200Response: JSONEncodable { - public var name: Int? + public var name: Int32? public init() {} @@ -18,7 +18,7 @@ public class Model200Response: JSONEncodable { // MARK: JSONEncodable func encodeToJSON() -> AnyObject { var nillableDictionary = [String:AnyObject?]() - nillableDictionary["name"] = self.name + nillableDictionary["name"] = self.name != nil ? NSNumber(int: self.name!) : nil let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] return dictionary } diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/ModelReturn.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/ModelReturn.swift index fbbcd5ec56f..f47a4055e2e 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/ModelReturn.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/ModelReturn.swift @@ -10,7 +10,7 @@ import Foundation public class ModelReturn: JSONEncodable { - public var _return: Int? + public var _return: Int32? public init() {} @@ -18,7 +18,7 @@ public class ModelReturn: JSONEncodable { // MARK: JSONEncodable func encodeToJSON() -> AnyObject { var nillableDictionary = [String:AnyObject?]() - nillableDictionary["return"] = self._return + nillableDictionary["return"] = self._return != nil ? NSNumber(int: self._return!) : nil let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] return dictionary } diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Name.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Name.swift index 986d6f00041..0acb1898b95 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Name.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Name.swift @@ -10,8 +10,8 @@ import Foundation public class Name: JSONEncodable { - public var name: Int? - public var snakeCase: Int? + public var name: Int32? + public var snakeCase: Int32? public init() {} @@ -19,8 +19,8 @@ public class Name: JSONEncodable { // MARK: JSONEncodable func encodeToJSON() -> AnyObject { var nillableDictionary = [String:AnyObject?]() - nillableDictionary["name"] = self.name - nillableDictionary["snake_case"] = self.snakeCase + nillableDictionary["name"] = self.name != nil ? NSNumber(int: self.name!) : nil + nillableDictionary["snake_case"] = self.snakeCase != nil ? NSNumber(int: self.snakeCase!) : nil let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] return dictionary } diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Order.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Order.swift index f309744da99..acdff556151 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Order.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Order.swift @@ -16,9 +16,9 @@ public class Order: JSONEncodable { case Delivered = "delivered" } - public var id: Int? - public var petId: Int? - public var quantity: Int? + public var id: Int64? + public var petId: Int64? + public var quantity: Int32? public var shipDate: NSDate? /** Order Status */ public var status: Status? @@ -30,9 +30,9 @@ public class Order: JSONEncodable { // MARK: JSONEncodable func encodeToJSON() -> AnyObject { var nillableDictionary = [String:AnyObject?]() - nillableDictionary["id"] = self.id - nillableDictionary["petId"] = self.petId - nillableDictionary["quantity"] = self.quantity + nillableDictionary["id"] = self.id != nil ? NSNumber(longLong: self.id!) : nil + nillableDictionary["petId"] = self.petId != nil ? NSNumber(longLong: self.petId!) : nil + nillableDictionary["quantity"] = self.quantity != nil ? NSNumber(int: self.quantity!) : nil nillableDictionary["shipDate"] = self.shipDate?.encodeToJSON() nillableDictionary["status"] = self.status?.rawValue nillableDictionary["complete"] = self.complete diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Pet.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Pet.swift index b1491df2516..16dff479d28 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Pet.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Pet.swift @@ -16,7 +16,7 @@ public class Pet: JSONEncodable { case Sold = "sold" } - public var id: Int? + public var id: Int64? public var category: Category? public var name: String? public var photoUrls: [String]? @@ -30,7 +30,7 @@ public class Pet: JSONEncodable { // MARK: JSONEncodable func encodeToJSON() -> AnyObject { var nillableDictionary = [String:AnyObject?]() - nillableDictionary["id"] = self.id + nillableDictionary["id"] = self.id != nil ? NSNumber(longLong: self.id!) : nil nillableDictionary["category"] = self.category?.encodeToJSON() nillableDictionary["name"] = self.name nillableDictionary["photoUrls"] = self.photoUrls?.encodeToJSON() diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/SpecialModelName.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/SpecialModelName.swift index d151c129965..f5faefff98c 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/SpecialModelName.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/SpecialModelName.swift @@ -10,7 +10,7 @@ import Foundation public class SpecialModelName: JSONEncodable { - public var specialPropertyName: Int? + public var specialPropertyName: Int64? public init() {} @@ -18,7 +18,7 @@ public class SpecialModelName: JSONEncodable { // MARK: JSONEncodable func encodeToJSON() -> AnyObject { var nillableDictionary = [String:AnyObject?]() - nillableDictionary["$special[property.name]"] = self.specialPropertyName + nillableDictionary["$special[property.name]"] = self.specialPropertyName != nil ? NSNumber(longLong: self.specialPropertyName!) : nil let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] return dictionary } diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Tag.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Tag.swift index edcd73a7a0c..ae5747accbe 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Tag.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Tag.swift @@ -10,7 +10,7 @@ import Foundation public class Tag: JSONEncodable { - public var id: Int? + public var id: Int64? public var name: String? @@ -19,7 +19,7 @@ public class Tag: JSONEncodable { // MARK: JSONEncodable func encodeToJSON() -> AnyObject { var nillableDictionary = [String:AnyObject?]() - nillableDictionary["id"] = self.id + nillableDictionary["id"] = self.id != nil ? NSNumber(longLong: self.id!) : nil nillableDictionary["name"] = self.name let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] return dictionary diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/User.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/User.swift index fa0ad3f5019..14f5f6bb6bb 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/User.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/User.swift @@ -10,7 +10,7 @@ import Foundation public class User: JSONEncodable { - public var id: Int? + public var id: Int64? public var username: String? public var firstName: String? public var lastName: String? @@ -18,7 +18,7 @@ public class User: JSONEncodable { public var password: String? public var phone: String? /** User Status */ - public var userStatus: Int? + public var userStatus: Int32? public init() {} @@ -26,14 +26,14 @@ public class User: JSONEncodable { // MARK: JSONEncodable func encodeToJSON() -> AnyObject { var nillableDictionary = [String:AnyObject?]() - nillableDictionary["id"] = self.id + nillableDictionary["id"] = self.id != nil ? NSNumber(longLong: self.id!) : nil nillableDictionary["username"] = self.username nillableDictionary["firstName"] = self.firstName nillableDictionary["lastName"] = self.lastName nillableDictionary["email"] = self.email nillableDictionary["password"] = self.password nillableDictionary["phone"] = self.phone - nillableDictionary["userStatus"] = self.userStatus + nillableDictionary["userStatus"] = self.userStatus != nil ? NSNumber(int: self.userStatus!) : nil let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] return dictionary }