From fca0d0f0f795fa974e4ed75160c98a5c98a09633 Mon Sep 17 00:00:00 2001 From: Christophe Jolif Date: Tue, 12 Apr 2016 16:48:33 +0200 Subject: [PATCH] make sure user is not forced to pass nil for optional parameters --- .../src/main/resources/swift/api.mustache | 6 +- .../Classes/Swaggers/APIs/PetAPI.swift | 260 +++++++++--------- .../Classes/Swaggers/APIs/StoreAPI.swift | 114 ++++---- .../Classes/Swaggers/APIs/UserAPI.swift | 38 +-- .../Classes/Swaggers/Models.swift | 9 +- .../Classes/Swaggers/Models/FormatTest.swift | 6 +- .../Swaggers/Models/InlineResponse200.swift | 12 +- 7 files changed, 224 insertions(+), 221 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/swift/api.mustache b/modules/swagger-codegen/src/main/resources/swift/api.mustache index ada4ec90d3..195fb88aee 100644 --- a/modules/swagger-codegen/src/main/resources/swift/api.mustache +++ b/modules/swagger-codegen/src/main/resources/swift/api.mustache @@ -23,7 +23,7 @@ public class {{classname}}: APIBase { - parameter {{paramName}}: ({{#isFormParam}}form{{/isFormParam}}{{#isQueryParam}}query{{/isQueryParam}}{{#isPathParam}}path{{/isPathParam}}{{#isHeaderParam}}header{{/isHeaderParam}}{{#isBodyParam}}body{{/isBodyParam}}) {{description}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{/allParams}} - parameter completion: completion handler to receive the data and the error objects */ - public class func {{operationId}}({{#allParams}}{{^secondaryParam}}{{paramName}} {{/secondaryParam}}{{paramName}}: {{{dataType}}}{{^required}}?{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}completion: (({{#returnType}}data: {{{returnType}}}?, {{/returnType}}error: ErrorType?) -> Void)) { + public class func {{operationId}}({{#allParams}}{{^secondaryParam}}{{paramName}} {{/secondaryParam}}{{paramName}}: {{{dataType}}}{{^required}}? = nil{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}completion: (({{#returnType}}data: {{{returnType}}}?, {{/returnType}}error: ErrorType?) -> Void)) { {{operationId}}WithRequestBuilder({{#allParams}}{{paramName}}: {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}).execute { (response, error) -> Void in completion({{#returnType}}data: response?.body, {{/returnType}}error: error); } @@ -37,7 +37,7 @@ public class {{classname}}: APIBase { - parameter {{paramName}}: ({{#isFormParam}}form{{/isFormParam}}{{#isQueryParam}}query{{/isQueryParam}}{{#isPathParam}}path{{/isPathParam}}{{#isHeaderParam}}header{{/isHeaderParam}}{{#isBodyParam}}body{{/isBodyParam}}) {{description}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{/allParams}} - returns: Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> */ - public class func {{operationId}}({{#allParams}}{{^secondaryParam}}{{paramName}} {{/secondaryParam}}{{paramName}}: {{{dataType}}}{{^required}}?{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> { + public class func {{operationId}}({{#allParams}}{{^secondaryParam}}{{paramName}} {{/secondaryParam}}{{paramName}}: {{{dataType}}}{{^required}}? = nil{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> { let deferred = Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}>.pendingPromise() {{operationId}}({{#allParams}}{{paramName}}: {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { {{#returnType}}data, {{/returnType}}error in if let error = error { @@ -69,7 +69,7 @@ public class {{classname}}: APIBase { - returns: RequestBuilder<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{description}} */ - public class func {{operationId}}WithRequestBuilder({{#allParams}}{{^secondaryParam}}{{paramName}} {{/secondaryParam}}{{paramName}}: {{{dataType}}}{{^required}}?{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> RequestBuilder<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> { + public class func {{operationId}}WithRequestBuilder({{#allParams}}{{^secondaryParam}}{{paramName}} {{/secondaryParam}}{{paramName}}: {{{dataType}}}{{^required}}? = nil{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> RequestBuilder<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> { {{^pathParams}}let{{/pathParams}}{{#pathParams}}{{^secondaryParam}}var{{/secondaryParam}}{{/pathParams}} path = "{{path}}"{{#pathParams}} path = path.stringByReplacingOccurrencesOfString("{{=<% %>=}}{<%paramName%>}<%={{ }}=%>", withString: "\({{paramName}})", options: .LiteralSearch, range: nil){{/pathParams}} let URLString = {{projectName}}API.basePath + path 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 347ccf2355..1d39c7885d 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift @@ -17,7 +17,7 @@ public class PetAPI: APIBase { - parameter body: (body) Pet object that needs to be added to the store (optional) - parameter completion: completion handler to receive the data and the error objects */ - public class func addPet(body body: Pet?, completion: ((error: ErrorType?) -> Void)) { + public class func addPet(body body: Pet? = nil, completion: ((error: ErrorType?) -> Void)) { addPetWithRequestBuilder(body: body).execute { (response, error) -> Void in completion(error: error); } @@ -29,7 +29,7 @@ public class PetAPI: APIBase { - parameter body: (body) Pet object that needs to be added to the store (optional) - returns: Promise */ - public class func addPet(body body: Pet?) -> Promise { + public class func addPet(body body: Pet? = nil) -> Promise { let deferred = Promise.pendingPromise() addPet(body: body) { error in if let error = error { @@ -53,7 +53,7 @@ public class PetAPI: APIBase { - returns: RequestBuilder */ - public class func addPetWithRequestBuilder(body body: Pet?) -> RequestBuilder { + public class func addPetWithRequestBuilder(body body: Pet? = nil) -> RequestBuilder { let path = "/pet" let URLString = PetstoreClientAPI.basePath + path let parameters = body?.encodeToJSON() as? [String:AnyObject] @@ -69,7 +69,7 @@ public class PetAPI: APIBase { - parameter body: (body) Pet object in the form of byte array (optional) - parameter completion: completion handler to receive the data and the error objects */ - public class func addPetUsingByteArray(body body: String?, completion: ((error: ErrorType?) -> Void)) { + public class func addPetUsingByteArray(body body: String? = nil, completion: ((error: ErrorType?) -> Void)) { addPetUsingByteArrayWithRequestBuilder(body: body).execute { (response, error) -> Void in completion(error: error); } @@ -81,7 +81,7 @@ public class PetAPI: APIBase { - parameter body: (body) Pet object in the form of byte array (optional) - returns: Promise */ - public class func addPetUsingByteArray(body body: String?) -> Promise { + public class func addPetUsingByteArray(body body: String? = nil) -> Promise { let deferred = Promise.pendingPromise() addPetUsingByteArray(body: body) { error in if let error = error { @@ -105,7 +105,7 @@ public class PetAPI: APIBase { - returns: RequestBuilder */ - public class func addPetUsingByteArrayWithRequestBuilder(body body: String?) -> RequestBuilder { + public class func addPetUsingByteArrayWithRequestBuilder(body body: String? = nil) -> RequestBuilder { let path = "/pet?testing_byte_array=true" let URLString = PetstoreClientAPI.basePath + path let parameters = body?.encodeToJSON() as? [String:AnyObject] @@ -176,7 +176,7 @@ public class PetAPI: APIBase { - parameter status: (query) Status values that need to be considered for query (optional, default to available) - parameter completion: completion handler to receive the data and the error objects */ - public class func findPetsByStatus(status status: [String]?, completion: ((data: [Pet]?, error: ErrorType?) -> Void)) { + public class func findPetsByStatus(status status: [String]? = nil, completion: ((data: [Pet]?, error: ErrorType?) -> Void)) { findPetsByStatusWithRequestBuilder(status: status).execute { (response, error) -> Void in completion(data: response?.body, error: error); } @@ -188,7 +188,7 @@ public class PetAPI: APIBase { - parameter status: (query) Status values that need to be considered for query (optional, default to available) - returns: Promise<[Pet]> */ - public class func findPetsByStatus(status status: [String]?) -> Promise<[Pet]> { + public class func findPetsByStatus(status status: [String]? = nil) -> Promise<[Pet]> { let deferred = Promise<[Pet]>.pendingPromise() findPetsByStatus(status: status) { data, error in if let error = error { @@ -207,20 +207,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 @@ -229,21 +229,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 @@ -252,13 +252,13 @@ public class PetAPI: APIBase { string -, contentType=application/xml}] +}] - parameter status: (query) Status values that need to be considered for query (optional, default to available) - returns: RequestBuilder<[Pet]> */ - public class func findPetsByStatusWithRequestBuilder(status status: [String]?) -> RequestBuilder<[Pet]> { + public class func findPetsByStatusWithRequestBuilder(status status: [String]? = nil) -> RequestBuilder<[Pet]> { let path = "/pet/findByStatus" let URLString = PetstoreClientAPI.basePath + path @@ -278,7 +278,7 @@ public class PetAPI: APIBase { - parameter tags: (query) Tags to filter by (optional) - parameter completion: completion handler to receive the data and the error objects */ - public class func findPetsByTags(tags tags: [String]?, completion: ((data: [Pet]?, error: ErrorType?) -> Void)) { + public class func findPetsByTags(tags tags: [String]? = nil, completion: ((data: [Pet]?, error: ErrorType?) -> Void)) { findPetsByTagsWithRequestBuilder(tags: tags).execute { (response, error) -> Void in completion(data: response?.body, error: error); } @@ -290,7 +290,7 @@ public class PetAPI: APIBase { - parameter tags: (query) Tags to filter by (optional) - returns: Promise<[Pet]> */ - public class func findPetsByTags(tags tags: [String]?) -> Promise<[Pet]> { + public class func findPetsByTags(tags tags: [String]? = nil) -> Promise<[Pet]> { let deferred = Promise<[Pet]>.pendingPromise() findPetsByTags(tags: tags) { data, error in if let error = error { @@ -309,20 +309,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 @@ -331,21 +331,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 @@ -354,13 +354,13 @@ public class PetAPI: APIBase { string -, contentType=application/xml}] +}] - parameter tags: (query) Tags to filter by (optional) - returns: RequestBuilder<[Pet]> */ - public class func findPetsByTagsWithRequestBuilder(tags tags: [String]?) -> RequestBuilder<[Pet]> { + public class func findPetsByTagsWithRequestBuilder(tags tags: [String]? = nil) -> RequestBuilder<[Pet]> { let path = "/pet/findByTags" let URLString = PetstoreClientAPI.basePath + path @@ -408,26 +408,26 @@ public class PetAPI: APIBase { Find pet by ID - 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 @@ -436,21 +436,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 @@ -459,7 +459,7 @@ public class PetAPI: APIBase { string -, contentType=application/xml}] +}] - parameter petId: (path) ID of pet that needs to be fetched @@ -512,46 +512,46 @@ public class PetAPI: APIBase { Fake endpoint to test inline arbitrary object return by 'Find pet by ID' - 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 @@ -604,14 +604,14 @@ public class PetAPI: APIBase { Fake endpoint to test byte array return by 'Find pet by ID' - 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 @@ -636,7 +636,7 @@ public class PetAPI: APIBase { - parameter body: (body) Pet object that needs to be added to the store (optional) - parameter completion: completion handler to receive the data and the error objects */ - public class func updatePet(body body: Pet?, completion: ((error: ErrorType?) -> Void)) { + public class func updatePet(body body: Pet? = nil, completion: ((error: ErrorType?) -> Void)) { updatePetWithRequestBuilder(body: body).execute { (response, error) -> Void in completion(error: error); } @@ -648,7 +648,7 @@ public class PetAPI: APIBase { - parameter body: (body) Pet object that needs to be added to the store (optional) - returns: Promise */ - public class func updatePet(body body: Pet?) -> Promise { + public class func updatePet(body body: Pet? = nil) -> Promise { let deferred = Promise.pendingPromise() updatePet(body: body) { error in if let error = error { @@ -672,7 +672,7 @@ public class PetAPI: APIBase { - returns: RequestBuilder */ - public class func updatePetWithRequestBuilder(body body: Pet?) -> RequestBuilder { + public class func updatePetWithRequestBuilder(body body: Pet? = nil) -> RequestBuilder { let path = "/pet" let URLString = PetstoreClientAPI.basePath + path let parameters = body?.encodeToJSON() as? [String:AnyObject] @@ -690,7 +690,7 @@ public class PetAPI: APIBase { - parameter status: (form) Updated status of the pet (optional) - parameter completion: completion handler to receive the data and the error objects */ - public class func updatePetWithForm(petId petId: String, name: String?, status: String?, completion: ((error: ErrorType?) -> Void)) { + public class func updatePetWithForm(petId petId: String, name: String? = nil, status: String? = nil, completion: ((error: ErrorType?) -> Void)) { updatePetWithFormWithRequestBuilder(petId: petId, name: name, status: status).execute { (response, error) -> Void in completion(error: error); } @@ -704,7 +704,7 @@ public class PetAPI: APIBase { - parameter status: (form) Updated status of the pet (optional) - returns: Promise */ - public class func updatePetWithForm(petId petId: String, name: String?, status: String?) -> Promise { + public class func updatePetWithForm(petId petId: String, name: String? = nil, status: String? = nil) -> Promise { let deferred = Promise.pendingPromise() updatePetWithForm(petId: petId, name: name, status: status) { error in if let error = error { @@ -730,7 +730,7 @@ public class PetAPI: APIBase { - returns: RequestBuilder */ - public class func updatePetWithFormWithRequestBuilder(petId petId: String, name: String?, status: String?) -> RequestBuilder { + public class func updatePetWithFormWithRequestBuilder(petId petId: String, name: String? = nil, status: String? = nil) -> RequestBuilder { var path = "/pet/{petId}" path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil) let URLString = PetstoreClientAPI.basePath + path @@ -754,7 +754,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: Int64, additionalMetadata: String?, _file: NSURL?, completion: ((error: ErrorType?) -> Void)) { + public class func uploadFile(petId petId: Int64, additionalMetadata: String? = nil, _file: NSURL? = nil, completion: ((error: ErrorType?) -> Void)) { uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, _file: _file).execute { (response, error) -> Void in completion(error: error); } @@ -768,7 +768,7 @@ public class PetAPI: APIBase { - parameter _file: (form) file to upload (optional) - returns: Promise */ - public class func uploadFile(petId petId: Int64, additionalMetadata: String?, _file: NSURL?) -> Promise { + public class func uploadFile(petId petId: Int64, additionalMetadata: String? = nil, _file: NSURL? = nil) -> Promise { let deferred = Promise.pendingPromise() uploadFile(petId: petId, additionalMetadata: additionalMetadata, _file: _file) { error in if let error = error { @@ -794,7 +794,7 @@ public class PetAPI: APIBase { - returns: RequestBuilder */ - public class func uploadFileWithRequestBuilder(petId petId: Int64, additionalMetadata: String?, _file: NSURL?) -> RequestBuilder { + public class func uploadFileWithRequestBuilder(petId petId: Int64, additionalMetadata: String? = nil, _file: NSURL? = nil) -> 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 94c311f1a4..f4f0cea288 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift @@ -69,7 +69,7 @@ public class StoreAPI: APIBase { - parameter status: (query) Status value that needs to be considered for query (optional, default to placed) - parameter completion: completion handler to receive the data and the error objects */ - public class func findOrdersByStatus(status status: String?, completion: ((data: [Order]?, error: ErrorType?) -> Void)) { + public class func findOrdersByStatus(status status: String? = nil, completion: ((data: [Order]?, error: ErrorType?) -> Void)) { findOrdersByStatusWithRequestBuilder(status: status).execute { (response, error) -> Void in completion(data: response?.body, error: error); } @@ -81,7 +81,7 @@ public class StoreAPI: APIBase { - parameter status: (query) Status value that needs to be considered for query (optional, default to placed) - returns: Promise<[Order]> */ - public class func findOrdersByStatus(status status: String?) -> Promise<[Order]> { + public class func findOrdersByStatus(status status: String? = nil) -> Promise<[Order]> { let deferred = Promise<[Order]>.pendingPromise() findOrdersByStatus(status: status) { data, error in if let error = error { @@ -103,42 +103,42 @@ 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) - returns: RequestBuilder<[Order]> */ - public class func findOrdersByStatusWithRequestBuilder(status status: String?) -> RequestBuilder<[Order]> { + public class func findOrdersByStatusWithRequestBuilder(status status: String? = nil) -> RequestBuilder<[Order]> { let path = "/store/findByStatus" let URLString = PetstoreClientAPI.basePath + path @@ -187,12 +187,12 @@ 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:Int32]> */ @@ -243,8 +243,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 */ @@ -294,42 +294,42 @@ public class StoreAPI: APIBase { Find purchase order by ID - 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 @@ -354,7 +354,7 @@ public class StoreAPI: APIBase { - parameter body: (body) order placed for purchasing the pet (optional) - parameter completion: completion handler to receive the data and the error objects */ - public class func placeOrder(body body: Order?, completion: ((data: Order?, error: ErrorType?) -> Void)) { + public class func placeOrder(body body: Order? = nil, completion: ((data: Order?, error: ErrorType?) -> Void)) { placeOrderWithRequestBuilder(body: body).execute { (response, error) -> Void in completion(data: response?.body, error: error); } @@ -366,7 +366,7 @@ public class StoreAPI: APIBase { - parameter body: (body) order placed for purchasing the pet (optional) - returns: Promise */ - public class func placeOrder(body body: Order?) -> Promise { + public class func placeOrder(body body: Order? = nil) -> Promise { let deferred = Promise.pendingPromise() placeOrder(body: body) { data, error in if let error = error { @@ -388,42 +388,42 @@ 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) - returns: RequestBuilder */ - public class func placeOrderWithRequestBuilder(body body: Order?) -> RequestBuilder { + public class func placeOrderWithRequestBuilder(body body: Order? = nil) -> RequestBuilder { let path = "/store/order" let URLString = PetstoreClientAPI.basePath + path let parameters = body?.encodeToJSON() as? [String:AnyObject] 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 4f1f36754c..6a522eb881 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift @@ -17,7 +17,7 @@ public class UserAPI: APIBase { - parameter body: (body) Created user object (optional) - parameter completion: completion handler to receive the data and the error objects */ - public class func createUser(body body: User?, completion: ((error: ErrorType?) -> Void)) { + public class func createUser(body body: User? = nil, completion: ((error: ErrorType?) -> Void)) { createUserWithRequestBuilder(body: body).execute { (response, error) -> Void in completion(error: error); } @@ -29,7 +29,7 @@ public class UserAPI: APIBase { - parameter body: (body) Created user object (optional) - returns: Promise */ - public class func createUser(body body: User?) -> Promise { + public class func createUser(body body: User? = nil) -> Promise { let deferred = Promise.pendingPromise() createUser(body: body) { error in if let error = error { @@ -50,7 +50,7 @@ public class UserAPI: APIBase { - returns: RequestBuilder */ - public class func createUserWithRequestBuilder(body body: User?) -> RequestBuilder { + public class func createUserWithRequestBuilder(body body: User? = nil) -> RequestBuilder { let path = "/user" let URLString = PetstoreClientAPI.basePath + path let parameters = body?.encodeToJSON() as? [String:AnyObject] @@ -66,7 +66,7 @@ public class UserAPI: APIBase { - parameter body: (body) List of user object (optional) - parameter completion: completion handler to receive the data and the error objects */ - public class func createUsersWithArrayInput(body body: [User]?, completion: ((error: ErrorType?) -> Void)) { + public class func createUsersWithArrayInput(body body: [User]? = nil, completion: ((error: ErrorType?) -> Void)) { createUsersWithArrayInputWithRequestBuilder(body: body).execute { (response, error) -> Void in completion(error: error); } @@ -78,7 +78,7 @@ public class UserAPI: APIBase { - parameter body: (body) List of user object (optional) - returns: Promise */ - public class func createUsersWithArrayInput(body body: [User]?) -> Promise { + public class func createUsersWithArrayInput(body body: [User]? = nil) -> Promise { let deferred = Promise.pendingPromise() createUsersWithArrayInput(body: body) { error in if let error = error { @@ -99,7 +99,7 @@ public class UserAPI: APIBase { - returns: RequestBuilder */ - public class func createUsersWithArrayInputWithRequestBuilder(body body: [User]?) -> RequestBuilder { + public class func createUsersWithArrayInputWithRequestBuilder(body body: [User]? = nil) -> RequestBuilder { let path = "/user/createWithArray" let URLString = PetstoreClientAPI.basePath + path let parameters = body?.encodeToJSON() as? [String:AnyObject] @@ -115,7 +115,7 @@ public class UserAPI: APIBase { - parameter body: (body) List of user object (optional) - parameter completion: completion handler to receive the data and the error objects */ - public class func createUsersWithListInput(body body: [User]?, completion: ((error: ErrorType?) -> Void)) { + public class func createUsersWithListInput(body body: [User]? = nil, completion: ((error: ErrorType?) -> Void)) { createUsersWithListInputWithRequestBuilder(body: body).execute { (response, error) -> Void in completion(error: error); } @@ -127,7 +127,7 @@ public class UserAPI: APIBase { - parameter body: (body) List of user object (optional) - returns: Promise */ - public class func createUsersWithListInput(body body: [User]?) -> Promise { + public class func createUsersWithListInput(body body: [User]? = nil) -> Promise { let deferred = Promise.pendingPromise() createUsersWithListInput(body: body) { error in if let error = error { @@ -148,7 +148,7 @@ public class UserAPI: APIBase { - returns: RequestBuilder */ - public class func createUsersWithListInputWithRequestBuilder(body body: [User]?) -> RequestBuilder { + public class func createUsersWithListInputWithRequestBuilder(body body: [User]? = nil) -> RequestBuilder { let path = "/user/createWithList" let URLString = PetstoreClientAPI.basePath + path let parameters = body?.encodeToJSON() as? [String:AnyObject] @@ -247,7 +247,7 @@ public class UserAPI: APIBase { Get user by user name - GET /user/{username} - - - examples: [{example={ + - examples: [{contentType=application/json, example={ "id" : 1, "username" : "johnp", "firstName" : "John", @@ -256,7 +256,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. @@ -282,7 +282,7 @@ public class UserAPI: APIBase { - parameter password: (query) The password for login in clear text (optional) - parameter completion: completion handler to receive the data and the error objects */ - public class func loginUser(username username: String?, password: String?, completion: ((data: String?, error: ErrorType?) -> Void)) { + public class func loginUser(username username: String? = nil, password: String? = nil, completion: ((data: String?, error: ErrorType?) -> Void)) { loginUserWithRequestBuilder(username: username, password: password).execute { (response, error) -> Void in completion(data: response?.body, error: error); } @@ -295,7 +295,7 @@ public class UserAPI: APIBase { - parameter password: (query) The password for login in clear text (optional) - returns: Promise */ - public class func loginUser(username username: String?, password: String?) -> Promise { + public class func loginUser(username username: String? = nil, password: String? = nil) -> Promise { let deferred = Promise.pendingPromise() loginUser(username: username, password: password) { data, error in if let error = error { @@ -311,15 +311,15 @@ public class UserAPI: APIBase { Logs user into the system - 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) - returns: RequestBuilder */ - public class func loginUserWithRequestBuilder(username username: String?, password: String?) -> RequestBuilder { + public class func loginUserWithRequestBuilder(username username: String? = nil, password: String? = nil) -> RequestBuilder { let path = "/user/login" let URLString = PetstoreClientAPI.basePath + path @@ -388,7 +388,7 @@ public class UserAPI: APIBase { - parameter body: (body) Updated user object (optional) - parameter completion: completion handler to receive the data and the error objects */ - public class func updateUser(username username: String, body: User?, completion: ((error: ErrorType?) -> Void)) { + public class func updateUser(username username: String, body: User? = nil, completion: ((error: ErrorType?) -> Void)) { updateUserWithRequestBuilder(username: username, body: body).execute { (response, error) -> Void in completion(error: error); } @@ -401,7 +401,7 @@ public class UserAPI: APIBase { - parameter body: (body) Updated user object (optional) - returns: Promise */ - public class func updateUser(username username: String, body: User?) -> Promise { + public class func updateUser(username username: String, body: User? = nil) -> Promise { let deferred = Promise.pendingPromise() updateUser(username: username, body: body) { error in if let error = error { @@ -423,7 +423,7 @@ public class UserAPI: APIBase { - returns: RequestBuilder */ - public class func updateUserWithRequestBuilder(username username: String, body: User?) -> RequestBuilder { + public class func updateUserWithRequestBuilder(username username: String, body: User? = nil) -> RequestBuilder { var path = "/user/{username}" path = path.stringByReplacingOccurrencesOfString("{username}", withString: "\(username)", options: .LiteralSearch, range: nil) let URLString = PetstoreClientAPI.basePath + path diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models.swift index bb8e7a7be4..f892a07320 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models.swift @@ -203,7 +203,8 @@ class Decoders { instance.byte = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["byte"]) instance.binary = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["binary"]) instance.date = Decoders.decodeOptional(clazz: NSDate.self, source: sourceDictionary["date"]) - instance.dateTime = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["dateTime"]) + instance.dateTime = Decoders.decodeOptional(clazz: NSDate.self, source: sourceDictionary["dateTime"]) + instance.password = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["password"]) return instance } @@ -216,12 +217,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.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) ?? "") - instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"]) - instance.photoUrls = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["photoUrls"]) return instance } diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/FormatTest.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/FormatTest.swift index ee2547d3e8..b84000125e 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/FormatTest.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/FormatTest.swift @@ -19,7 +19,8 @@ public class FormatTest: JSONEncodable { public var byte: String? public var binary: String? public var date: NSDate? - public var dateTime: String? + public var dateTime: NSDate? + public var password: String? public init() {} @@ -37,7 +38,8 @@ public class FormatTest: JSONEncodable { nillableDictionary["byte"] = self.byte nillableDictionary["binary"] = self.binary nillableDictionary["date"] = self.date?.encodeToJSON() - nillableDictionary["dateTime"] = self.dateTime + nillableDictionary["dateTime"] = self.dateTime?.encodeToJSON() + nillableDictionary["password"] = self.password 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 6e3ce5aeab..a9397e868b 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/InlineResponse200.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/InlineResponse200.swift @@ -14,26 +14,26 @@ public class InlineResponse200: JSONEncodable { case Pending = "pending" case Sold = "sold" } - public var tags: [Tag]? + 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() {} // MARK: JSONEncodable func encodeToJSON() -> AnyObject { var nillableDictionary = [String:AnyObject?]() - nillableDictionary["tags"] = self.tags?.encodeToJSON() + nillableDictionary["photoUrls"] = self.photoUrls?.encodeToJSON() + nillableDictionary["name"] = self.name nillableDictionary["id"] = self.id?.encodeToJSON() nillableDictionary["id"] = self.id?.encodeToJSON() nillableDictionary["category"] = self.category + nillableDictionary["tags"] = self.tags?.encodeToJSON() nillableDictionary["status"] = self.status?.rawValue - nillableDictionary["name"] = self.name - nillableDictionary["photoUrls"] = self.photoUrls?.encodeToJSON() let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] return dictionary }