Generates Int32/Int64 for Swift when those are the required formats. Fixes #2133.

This commit is contained in:
Christophe Jolif 2016-03-17 22:44:21 +01:00
parent 6ecf083b0f
commit 677890fc08
17 changed files with 261 additions and 245 deletions

View File

@ -74,6 +74,8 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
languageSpecificPrimitives = new HashSet<String>(
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");

View File

@ -56,6 +56,12 @@ class Decoders {
static func decode<T>(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
}

View File

@ -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}}

View File

@ -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<Void>
*/
public class func deletePet(petId petId: Int) -> Promise<Void> {
public class func deletePet(petId petId: Int64) -> Promise<Void> {
let deferred = Promise<Void>.pendingPromise()
deletePet(petId: petId) { error in
if let error = error {
@ -171,7 +171,7 @@ public class PetAPI: APIBase {
- returns: RequestBuilder<Void>
*/
public class func deletePetWithRequestBuilder(petId petId: Int) -> RequestBuilder<Void> {
public class func deletePetWithRequestBuilder(petId petId: Int64) -> RequestBuilder<Void> {
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=<Pet>
"tags" : [ {
"name" : "aeiou",
"id" : 123456789
} ],
"status" : "aeiou"
} ]}, {contentType=application/xml, example=<Pet>
<id>123456</id>
<name>doggie</name>
<photoUrls>
@ -247,21 +247,21 @@ public class PetAPI: APIBase {
<tags>
</tags>
<status>string</status>
</Pet>, contentType=application/xml}]
- examples: [{example=[ {
"tags" : [ {
"id" : 123456789,
"name" : "aeiou"
} ],
</Pet>}]
- 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=<Pet>
"tags" : [ {
"name" : "aeiou",
"id" : 123456789
} ],
"status" : "aeiou"
} ]}, {contentType=application/xml, example=<Pet>
<id>123456</id>
<name>doggie</name>
<photoUrls>
@ -270,7 +270,7 @@ public class PetAPI: APIBase {
<tags>
</tags>
<status>string</status>
</Pet>, contentType=application/xml}]
</Pet>}]
- 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=<Pet>
"tags" : [ {
"name" : "aeiou",
"id" : 123456789
} ],
"status" : "aeiou"
} ]}, {contentType=application/xml, example=<Pet>
<id>123456</id>
<name>doggie</name>
<photoUrls>
@ -353,21 +353,21 @@ public class PetAPI: APIBase {
<tags>
</tags>
<status>string</status>
</Pet>, contentType=application/xml}]
- examples: [{example=[ {
"tags" : [ {
"id" : 123456789,
"name" : "aeiou"
} ],
</Pet>}]
- 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=<Pet>
"tags" : [ {
"name" : "aeiou",
"id" : 123456789
} ],
"status" : "aeiou"
} ]}, {contentType=application/xml, example=<Pet>
<id>123456</id>
<name>doggie</name>
<photoUrls>
@ -376,7 +376,7 @@ public class PetAPI: APIBase {
<tags>
</tags>
<status>string</status>
</Pet>, contentType=application/xml}]
</Pet>}]
- 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<Pet>
*/
public class func getPetById(petId petId: Int) -> Promise<Pet> {
public class func getPetById(petId petId: Int64) -> Promise<Pet> {
let deferred = Promise<Pet>.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=<Pet>
"tags" : [ {
"name" : "aeiou",
"id" : 123456789
} ],
"status" : "aeiou"
}}, {contentType=application/xml, example=<Pet>
<id>123456</id>
<name>doggie</name>
<photoUrls>
@ -462,21 +462,21 @@ public class PetAPI: APIBase {
<tags>
</tags>
<status>string</status>
</Pet>, contentType=application/xml}]
- examples: [{example={
"tags" : [ {
"id" : 123456789,
"name" : "aeiou"
} ],
</Pet>}]
- 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=<Pet>
"tags" : [ {
"name" : "aeiou",
"id" : 123456789
} ],
"status" : "aeiou"
}}, {contentType=application/xml, example=<Pet>
<id>123456</id>
<name>doggie</name>
<photoUrls>
@ -485,13 +485,13 @@ public class PetAPI: APIBase {
<tags>
</tags>
<status>string</status>
</Pet>, contentType=application/xml}]
</Pet>}]
- parameter petId: (path) ID of pet that needs to be fetched
- returns: RequestBuilder<Pet>
*/
public class func getPetByIdWithRequestBuilder(petId petId: Int) -> RequestBuilder<Pet> {
public class func getPetByIdWithRequestBuilder(petId petId: Int64) -> RequestBuilder<Pet> {
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<InlineResponse200>
*/
public class func getPetByIdInObject(petId petId: Int) -> Promise<InlineResponse200> {
public class func getPetByIdInObject(petId petId: Int64) -> Promise<InlineResponse200> {
let deferred = Promise<InlineResponse200>.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=<null>
"id" : 123456789,
"category" : "{}",
"tags" : [ {
"name" : "aeiou",
"id" : 123456789
} ],
"status" : "aeiou"
}}, {contentType=application/xml, example=<null>
<photoUrls>string</photoUrls>
<name>doggie</name>
<id>123456</id>
<category>not implemented io.swagger.models.properties.ObjectProperty@37ff6855</category>
<status>string</status>
<name>doggie</name>
<photoUrls>string</photoUrls>
</null>, contentType=application/xml}]
- examples: [{example={
"id" : 123456789,
"tags" : [ {
"id" : 123456789,
"name" : "aeiou"
} ],
"category" : "{}",
"status" : "aeiou",
</null>}]
- examples: [{contentType=application/json, example={
"photoUrls" : [ "aeiou" ],
"name" : "doggie",
"photoUrls" : [ "aeiou" ]
}, contentType=application/json}, {example=<null>
"id" : 123456789,
"category" : "{}",
"tags" : [ {
"name" : "aeiou",
"id" : 123456789
} ],
"status" : "aeiou"
}}, {contentType=application/xml, example=<null>
<photoUrls>string</photoUrls>
<name>doggie</name>
<id>123456</id>
<category>not implemented io.swagger.models.properties.ObjectProperty@37ff6855</category>
<status>string</status>
<name>doggie</name>
<photoUrls>string</photoUrls>
</null>, contentType=application/xml}]
</null>}]
- parameter petId: (path) ID of pet that needs to be fetched
- returns: RequestBuilder<InlineResponse200>
*/
public class func getPetByIdInObjectWithRequestBuilder(petId petId: Int) -> RequestBuilder<InlineResponse200> {
public class func getPetByIdInObjectWithRequestBuilder(petId petId: Int64) -> RequestBuilder<InlineResponse200> {
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<String>
*/
public class func petPetIdtestingByteArraytrueGet(petId petId: Int) -> Promise<String> {
public class func petPetIdtestingByteArraytrueGet(petId petId: Int64) -> Promise<String> {
let deferred = Promise<String>.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<String>
*/
public class func petPetIdtestingByteArraytrueGetWithRequestBuilder(petId petId: Int) -> RequestBuilder<String> {
public class func petPetIdtestingByteArraytrueGetWithRequestBuilder(petId petId: Int64) -> RequestBuilder<String> {
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<Void>
*/
public class func uploadFile(petId petId: Int, additionalMetadata: String?, _file: NSURL?) -> Promise<Void> {
public class func uploadFile(petId petId: Int64, additionalMetadata: String?, _file: NSURL?) -> Promise<Void> {
let deferred = Promise<Void>.pendingPromise()
uploadFile(petId: petId, additionalMetadata: additionalMetadata, _file: _file) { error in
if let error = error {
@ -841,7 +841,7 @@ public class PetAPI: APIBase {
- returns: RequestBuilder<Void>
*/
public class func uploadFileWithRequestBuilder(petId petId: Int, additionalMetadata: String?, _file: NSURL?) -> RequestBuilder<Void> {
public class func uploadFileWithRequestBuilder(petId petId: Int64, additionalMetadata: String?, _file: NSURL?) -> RequestBuilder<Void> {
var path = "/pet/{petId}/uploadImage"
path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil)
let URLString = PetstoreClientAPI.basePath + path

View File

@ -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=<Order>
"id" : 123456789,
"shipDate" : "2000-01-23T04:56:07.000+0000",
"complete" : true,
"status" : "aeiou"
} ]}, {contentType=application/xml, example=<Order>
<id>123456</id>
<petId>123456</petId>
<quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status>
<complete>true</complete>
</Order>, contentType=application/xml}]
- examples: [{example=[ {
"id" : 123456789,
</Order>}]
- 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=<Order>
"id" : 123456789,
"shipDate" : "2000-01-23T04:56:07.000+0000",
"complete" : true,
"status" : "aeiou"
} ]}, {contentType=application/xml, example=<Order>
<id>123456</id>
<petId>123456</petId>
<quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status>
<complete>true</complete>
</Order>, contentType=application/xml}]
</Order>}]
- 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<AnyObject>
*/
@ -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=<Order>
"id" : 123456789,
"shipDate" : "2000-01-23T04:56:07.000+0000",
"complete" : true,
"status" : "aeiou"
}}, {contentType=application/xml, example=<Order>
<id>123456</id>
<petId>123456</petId>
<quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status>
<complete>true</complete>
</Order>, contentType=application/xml}]
- examples: [{example={
"id" : 123456789,
</Order>}]
- 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=<Order>
"id" : 123456789,
"shipDate" : "2000-01-23T04:56:07.000+0000",
"complete" : true,
"status" : "aeiou"
}}, {contentType=application/xml, example=<Order>
<id>123456</id>
<petId>123456</petId>
<quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status>
<complete>true</complete>
</Order>, contentType=application/xml}]
</Order>}]
- 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=<Order>
"id" : 123456789,
"shipDate" : "2000-01-23T04:56:07.000+0000",
"complete" : true,
"status" : "aeiou"
}}, {contentType=application/xml, example=<Order>
<id>123456</id>
<petId>123456</petId>
<quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status>
<complete>true</complete>
</Order>, contentType=application/xml}]
- examples: [{example={
"id" : 123456789,
</Order>}]
- 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=<Order>
"id" : 123456789,
"shipDate" : "2000-01-23T04:56:07.000+0000",
"complete" : true,
"status" : "aeiou"
}}, {contentType=application/xml, example=<Order>
<id>123456</id>
<petId>123456</petId>
<quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status>
<complete>true</complete>
</Order>, contentType=application/xml}]
</Order>}]
- parameter body: (body) order placed for purchasing the pet (optional)

View File

@ -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)

View File

@ -56,6 +56,12 @@ class Decoders {
static func decode<T>(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
}

View File

@ -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

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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

View File

@ -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()

View File

@ -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
}

View File

@ -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

View File

@ -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
}