mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 03:18:53 +00:00
Update Swift API method generation for ease of use
This commit is contained in:
parent
005584cf2a
commit
ac3ab477d3
@ -13,6 +13,40 @@ extension {{projectName}}API {
|
||||
/** {{description}} */{{/description}}
|
||||
public class {{classname}}: APIBase {
|
||||
{{#operation}}
|
||||
/**
|
||||
{{#summary}}
|
||||
{{{summary}}}
|
||||
{{/summary}}{{#allParams}}
|
||||
- parameter {{paramName}}: ({{#isFormParam}}form{{/isFormParam}}{{#isQueryParam}}query{{/isQueryParam}}{{#isPathParam}}path{{/isPathParam}}{{#isHeaderParam}}header{{/isHeaderParam}}{{#isBodyParam}}body{{/isBodyParam}}) {{description}}{{/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)) {
|
||||
{{operationId}}WithRequestBuilder({{#allParams}}{{paramName}}: {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}).execute { (response, error) -> Void in
|
||||
completion({{#returnType}}data: response?.body, {{/returnType}}error: error);
|
||||
}
|
||||
}
|
||||
|
||||
{{#usePromiseKit}}
|
||||
/**
|
||||
{{#summary}}
|
||||
{{{summary}}}
|
||||
{{/summary}}{{#allParams}}
|
||||
- parameter {{paramName}}: ({{#isFormParam}}form{{/isFormParam}}{{#isQueryParam}}query{{/isQueryParam}}{{#isPathParam}}path{{/isPathParam}}{{#isHeaderParam}}header{{/isHeaderParam}}{{#isBodyParam}}body{{/isBodyParam}}) {{description}}{{/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}}> {
|
||||
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 {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill({{#returnType}}data!{{/returnType}})
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
{{/usePromiseKit}}
|
||||
|
||||
/**
|
||||
{{#summary}}
|
||||
{{{summary}}}
|
||||
@ -32,7 +66,7 @@ extension {{projectName}}API {
|
||||
|
||||
- returns: RequestBuilder<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{description}}
|
||||
*/
|
||||
public class func {{operationId}}({{#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}}?{{/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
|
||||
|
@ -12,6 +12,38 @@ extension PetstoreClientAPI {
|
||||
|
||||
public class PetAPI: APIBase {
|
||||
|
||||
/**
|
||||
|
||||
Update an existing pet
|
||||
|
||||
- parameter body: (body) Pet object that needs to be added to the store
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
public class func updatePet(body body: Pet?, completion: ((error: ErrorType?) -> Void)) {
|
||||
updatePetWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(error: error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Update an existing pet
|
||||
|
||||
- parameter body: (body) Pet object that needs to be added to the store
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
public class func updatePet(body body: Pet?) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pendingPromise()
|
||||
updatePet(body: body) { error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill()
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Update an existing pet
|
||||
@ -26,7 +58,7 @@ extension PetstoreClientAPI {
|
||||
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
public class func updatePet(body body: Pet?) -> RequestBuilder<Void> {
|
||||
public class func updatePetWithRequestBuilder(body body: Pet?) -> RequestBuilder<Void> {
|
||||
let path = "/pet"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
|
||||
@ -37,6 +69,38 @@ extension PetstoreClientAPI {
|
||||
return requestBuilder.init(method: "PUT", URLString: URLString, parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Add a new pet to the store
|
||||
|
||||
- parameter body: (body) Pet object that needs to be added to the store
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
public class func addPet(body body: Pet?, completion: ((error: ErrorType?) -> Void)) {
|
||||
addPetWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(error: error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Add a new pet to the store
|
||||
|
||||
- parameter body: (body) Pet object that needs to be added to the store
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
public class func addPet(body body: Pet?) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pendingPromise()
|
||||
addPet(body: body) { error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill()
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Add a new pet to the store
|
||||
@ -51,7 +115,7 @@ extension PetstoreClientAPI {
|
||||
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
public class func addPet(body body: Pet?) -> RequestBuilder<Void> {
|
||||
public class func addPetWithRequestBuilder(body body: Pet?) -> RequestBuilder<Void> {
|
||||
let path = "/pet"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
|
||||
@ -62,6 +126,38 @@ extension PetstoreClientAPI {
|
||||
return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Finds Pets by status
|
||||
|
||||
- parameter status: (query) Status values that need to be considered for filter
|
||||
- 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)) {
|
||||
findPetsByStatusWithRequestBuilder(status: status).execute { (response, error) -> Void in
|
||||
completion(data: response?.body, error: error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Finds Pets by status
|
||||
|
||||
- parameter status: (query) Status values that need to be considered for filter
|
||||
- returns: Promise<[Pet]>
|
||||
*/
|
||||
public class func findPetsByStatus(status status: [String]?) -> Promise<[Pet]> {
|
||||
let deferred = Promise<[Pet]>.pendingPromise()
|
||||
findPetsByStatus(status: status) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Finds Pets by status
|
||||
@ -122,7 +218,7 @@ extension PetstoreClientAPI {
|
||||
|
||||
- returns: RequestBuilder<[Pet]>
|
||||
*/
|
||||
public class func findPetsByStatus(status status: [String]?) -> RequestBuilder<[Pet]> {
|
||||
public class func findPetsByStatusWithRequestBuilder(status status: [String]?) -> RequestBuilder<[Pet]> {
|
||||
let path = "/pet/findByStatus"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
|
||||
@ -136,6 +232,38 @@ extension PetstoreClientAPI {
|
||||
return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Finds Pets by tags
|
||||
|
||||
- parameter tags: (query) Tags to filter by
|
||||
- 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)) {
|
||||
findPetsByTagsWithRequestBuilder(tags: tags).execute { (response, error) -> Void in
|
||||
completion(data: response?.body, error: error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Finds Pets by tags
|
||||
|
||||
- parameter tags: (query) Tags to filter by
|
||||
- returns: Promise<[Pet]>
|
||||
*/
|
||||
public class func findPetsByTags(tags tags: [String]?) -> Promise<[Pet]> {
|
||||
let deferred = Promise<[Pet]>.pendingPromise()
|
||||
findPetsByTags(tags: tags) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Finds Pets by tags
|
||||
@ -196,7 +324,7 @@ extension PetstoreClientAPI {
|
||||
|
||||
- returns: RequestBuilder<[Pet]>
|
||||
*/
|
||||
public class func findPetsByTags(tags tags: [String]?) -> RequestBuilder<[Pet]> {
|
||||
public class func findPetsByTagsWithRequestBuilder(tags tags: [String]?) -> RequestBuilder<[Pet]> {
|
||||
let path = "/pet/findByTags"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
|
||||
@ -210,6 +338,38 @@ extension PetstoreClientAPI {
|
||||
return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Find pet by ID
|
||||
|
||||
- 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)) {
|
||||
getPetByIdWithRequestBuilder(petId: petId).execute { (response, error) -> Void in
|
||||
completion(data: response?.body, error: error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Find pet by ID
|
||||
|
||||
- parameter petId: (path) ID of pet that needs to be fetched
|
||||
- returns: Promise<Pet>
|
||||
*/
|
||||
public class func getPetById(petId petId: Int) -> Promise<Pet> {
|
||||
let deferred = Promise<Pet>.pendingPromise()
|
||||
getPetById(petId: petId) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Find pet by ID
|
||||
@ -219,6 +379,9 @@ extension PetstoreClientAPI {
|
||||
- API Key:
|
||||
- type: apiKey api_key
|
||||
- name: api_key
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- examples: [{example={
|
||||
"tags" : [ {
|
||||
"id" : 123456789,
|
||||
@ -270,7 +433,7 @@ extension PetstoreClientAPI {
|
||||
|
||||
- returns: RequestBuilder<Pet>
|
||||
*/
|
||||
public class func getPetById(petId petId: Int) -> RequestBuilder<Pet> {
|
||||
public class func getPetByIdWithRequestBuilder(petId petId: Int) -> RequestBuilder<Pet> {
|
||||
var path = "/pet/{petId}"
|
||||
path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
@ -283,6 +446,42 @@ extension PetstoreClientAPI {
|
||||
return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Updates a pet in the store with form data
|
||||
|
||||
- parameter petId: (path) ID of pet that needs to be updated
|
||||
- parameter name: (form) Updated name of the pet
|
||||
- parameter status: (form) Updated status of the pet
|
||||
- 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)) {
|
||||
updatePetWithFormWithRequestBuilder(petId: petId, name: name, status: status).execute { (response, error) -> Void in
|
||||
completion(error: error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Updates a pet in the store with form data
|
||||
|
||||
- parameter petId: (path) ID of pet that needs to be updated
|
||||
- parameter name: (form) Updated name of the pet
|
||||
- parameter status: (form) Updated status of the pet
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
public class func updatePetWithForm(petId petId: String, name: String?, status: String?) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pendingPromise()
|
||||
updatePetWithForm(petId: petId, name: name, status: status) { error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill()
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Updates a pet in the store with form data
|
||||
@ -299,7 +498,7 @@ extension PetstoreClientAPI {
|
||||
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
public class func updatePetWithForm(petId petId: String, name: String?, status: String?) -> RequestBuilder<Void> {
|
||||
public class func updatePetWithFormWithRequestBuilder(petId petId: String, name: String?, status: String?) -> RequestBuilder<Void> {
|
||||
var path = "/pet/{petId}"
|
||||
path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
@ -315,6 +514,38 @@ extension PetstoreClientAPI {
|
||||
return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Deletes a pet
|
||||
|
||||
- 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)) {
|
||||
deletePetWithRequestBuilder(petId: petId).execute { (response, error) -> Void in
|
||||
completion(error: error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Deletes a pet
|
||||
|
||||
- parameter petId: (path) Pet id to delete
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
public class func deletePet(petId petId: Int) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pendingPromise()
|
||||
deletePet(petId: petId) { error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill()
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Deletes a pet
|
||||
@ -329,7 +560,7 @@ extension PetstoreClientAPI {
|
||||
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
public class func deletePet(petId petId: Int) -> RequestBuilder<Void> {
|
||||
public class func deletePetWithRequestBuilder(petId petId: Int) -> RequestBuilder<Void> {
|
||||
var path = "/pet/{petId}"
|
||||
path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
@ -342,6 +573,42 @@ extension PetstoreClientAPI {
|
||||
return requestBuilder.init(method: "DELETE", URLString: URLString, parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
uploads an image
|
||||
|
||||
- parameter petId: (path) ID of pet to update
|
||||
- parameter additionalMetadata: (form) Additional data to pass to server
|
||||
- parameter file: (form) file to upload
|
||||
- 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)) {
|
||||
uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, file: file).execute { (response, error) -> Void in
|
||||
completion(error: error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
uploads an image
|
||||
|
||||
- parameter petId: (path) ID of pet to update
|
||||
- parameter additionalMetadata: (form) Additional data to pass to server
|
||||
- parameter file: (form) file to upload
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
public class func uploadFile(petId petId: Int, additionalMetadata: String?, file: NSURL?) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pendingPromise()
|
||||
uploadFile(petId: petId, additionalMetadata: additionalMetadata, file: file) { error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill()
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
uploads an image
|
||||
@ -358,7 +625,7 @@ extension PetstoreClientAPI {
|
||||
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
public class func uploadFile(petId petId: Int, additionalMetadata: String?, file: NSURL?) -> RequestBuilder<Void> {
|
||||
public class func uploadFileWithRequestBuilder(petId petId: Int, 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
|
||||
@ -374,6 +641,38 @@ extension PetstoreClientAPI {
|
||||
return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Fake endpoint to test byte array return by 'Find pet by ID'
|
||||
|
||||
- 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)) {
|
||||
petPetIdtestingByteArraytrueGetWithRequestBuilder(petId: petId).execute { (response, error) -> Void in
|
||||
completion(data: response?.body, error: error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Fake endpoint to test byte array return by 'Find pet by ID'
|
||||
|
||||
- parameter petId: (path) ID of pet that needs to be fetched
|
||||
- returns: Promise<String>
|
||||
*/
|
||||
public class func petPetIdtestingByteArraytrueGet(petId petId: Int) -> Promise<String> {
|
||||
let deferred = Promise<String>.pendingPromise()
|
||||
petPetIdtestingByteArraytrueGet(petId: petId) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Fake endpoint to test byte array return by 'Find pet by ID'
|
||||
@ -383,6 +682,9 @@ extension PetstoreClientAPI {
|
||||
- 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}]
|
||||
|
||||
@ -390,7 +692,7 @@ extension PetstoreClientAPI {
|
||||
|
||||
- returns: RequestBuilder<String>
|
||||
*/
|
||||
public class func getPetByIdWithByteArray(petId petId: Int) -> RequestBuilder<String> {
|
||||
public class func petPetIdtestingByteArraytrueGetWithRequestBuilder(petId petId: Int) -> 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
|
||||
@ -403,6 +705,38 @@ extension PetstoreClientAPI {
|
||||
return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Fake endpoint to test byte array in body parameter for adding a new pet to the store
|
||||
|
||||
- parameter body: (body) Pet object in the form of byte array
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
public class func addPetUsingByteArray(body body: String?, completion: ((error: ErrorType?) -> Void)) {
|
||||
addPetUsingByteArrayWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(error: error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Fake endpoint to test byte array in body parameter for adding a new pet to the store
|
||||
|
||||
- parameter body: (body) Pet object in the form of byte array
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
public class func addPetUsingByteArray(body body: String?) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pendingPromise()
|
||||
addPetUsingByteArray(body: body) { error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill()
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Fake endpoint to test byte array in body parameter for adding a new pet to the store
|
||||
@ -417,7 +751,7 @@ extension PetstoreClientAPI {
|
||||
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
public class func addPetUsingByteArray(body body: String?) -> RequestBuilder<Void> {
|
||||
public class func addPetUsingByteArrayWithRequestBuilder(body body: String?) -> RequestBuilder<Void> {
|
||||
let path = "/pet?testing_byte_array=true"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
|
||||
|
@ -12,6 +12,36 @@ extension PetstoreClientAPI {
|
||||
|
||||
public class StoreAPI: APIBase {
|
||||
|
||||
/**
|
||||
|
||||
Returns pet inventories by status
|
||||
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
public class func getInventory(completion: ((data: [String:Int]?, error: ErrorType?) -> Void)) {
|
||||
getInventoryWithRequestBuilder().execute { (response, error) -> Void in
|
||||
completion(data: response?.body, error: error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Returns pet inventories by status
|
||||
|
||||
- returns: Promise<[String:Int]>
|
||||
*/
|
||||
public class func getInventory() -> Promise<[String:Int]> {
|
||||
let deferred = Promise<[String:Int]>.pendingPromise()
|
||||
getInventory() { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Returns pet inventories by status
|
||||
@ -30,7 +60,7 @@ extension PetstoreClientAPI {
|
||||
|
||||
- returns: RequestBuilder<[String:Int]>
|
||||
*/
|
||||
public class func getInventory() -> RequestBuilder<[String:Int]> {
|
||||
public class func getInventoryWithRequestBuilder() -> RequestBuilder<[String:Int]> {
|
||||
let path = "/store/inventory"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
|
||||
@ -42,12 +72,50 @@ extension PetstoreClientAPI {
|
||||
return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Place an order for a pet
|
||||
|
||||
- parameter body: (body) order placed for purchasing the pet
|
||||
- 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)) {
|
||||
placeOrderWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(data: response?.body, error: error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Place an order for a pet
|
||||
|
||||
- parameter body: (body) order placed for purchasing the pet
|
||||
- returns: Promise<Order>
|
||||
*/
|
||||
public class func placeOrder(body body: Order?) -> Promise<Order> {
|
||||
let deferred = Promise<Order>.pendingPromise()
|
||||
placeOrder(body: body) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Place an order for a pet
|
||||
|
||||
- POST /store/order
|
||||
-
|
||||
- API Key:
|
||||
- type: apiKey x-test_api_client_id
|
||||
- name: test_api_client_id
|
||||
- API Key:
|
||||
- type: apiKey x-test_api_client_secret
|
||||
- name: test_api_client_secret
|
||||
- examples: [{example={
|
||||
"id" : 123456789,
|
||||
"petId" : 123456789,
|
||||
@ -83,7 +151,7 @@ extension PetstoreClientAPI {
|
||||
|
||||
- returns: RequestBuilder<Order>
|
||||
*/
|
||||
public class func placeOrder(body body: Order?) -> RequestBuilder<Order> {
|
||||
public class func placeOrderWithRequestBuilder(body body: Order?) -> RequestBuilder<Order> {
|
||||
let path = "/store/order"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
|
||||
@ -94,12 +162,50 @@ extension PetstoreClientAPI {
|
||||
return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Find purchase order by ID
|
||||
|
||||
- parameter orderId: (path) ID of pet that needs to be fetched
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
public class func getOrderById(orderId orderId: String, completion: ((data: Order?, error: ErrorType?) -> Void)) {
|
||||
getOrderByIdWithRequestBuilder(orderId: orderId).execute { (response, error) -> Void in
|
||||
completion(data: response?.body, error: error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Find purchase order by ID
|
||||
|
||||
- parameter orderId: (path) ID of pet that needs to be fetched
|
||||
- returns: Promise<Order>
|
||||
*/
|
||||
public class func getOrderById(orderId orderId: String) -> Promise<Order> {
|
||||
let deferred = Promise<Order>.pendingPromise()
|
||||
getOrderById(orderId: orderId) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
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,
|
||||
"petId" : 123456789,
|
||||
@ -135,7 +241,7 @@ extension PetstoreClientAPI {
|
||||
|
||||
- returns: RequestBuilder<Order>
|
||||
*/
|
||||
public class func getOrderById(orderId orderId: String) -> RequestBuilder<Order> {
|
||||
public class func getOrderByIdWithRequestBuilder(orderId orderId: String) -> RequestBuilder<Order> {
|
||||
var path = "/store/order/{orderId}"
|
||||
path = path.stringByReplacingOccurrencesOfString("{orderId}", withString: "\(orderId)", options: .LiteralSearch, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
@ -148,6 +254,38 @@ extension PetstoreClientAPI {
|
||||
return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Delete purchase order by ID
|
||||
|
||||
- parameter orderId: (path) ID of the order that needs to be deleted
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
public class func deleteOrder(orderId orderId: String, completion: ((error: ErrorType?) -> Void)) {
|
||||
deleteOrderWithRequestBuilder(orderId: orderId).execute { (response, error) -> Void in
|
||||
completion(error: error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Delete purchase order by ID
|
||||
|
||||
- parameter orderId: (path) ID of the order that needs to be deleted
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
public class func deleteOrder(orderId orderId: String) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pendingPromise()
|
||||
deleteOrder(orderId: orderId) { error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill()
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Delete purchase order by ID
|
||||
@ -159,7 +297,7 @@ extension PetstoreClientAPI {
|
||||
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
public class func deleteOrder(orderId orderId: String) -> RequestBuilder<Void> {
|
||||
public class func deleteOrderWithRequestBuilder(orderId orderId: String) -> RequestBuilder<Void> {
|
||||
var path = "/store/order/{orderId}"
|
||||
path = path.stringByReplacingOccurrencesOfString("{orderId}", withString: "\(orderId)", options: .LiteralSearch, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
|
@ -12,6 +12,38 @@ extension PetstoreClientAPI {
|
||||
|
||||
public class UserAPI: APIBase {
|
||||
|
||||
/**
|
||||
|
||||
Create user
|
||||
|
||||
- parameter body: (body) Created user object
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
public class func createUser(body body: User?, completion: ((error: ErrorType?) -> Void)) {
|
||||
createUserWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(error: error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Create user
|
||||
|
||||
- parameter body: (body) Created user object
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
public class func createUser(body body: User?) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pendingPromise()
|
||||
createUser(body: body) { error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill()
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Create user
|
||||
@ -23,7 +55,7 @@ extension PetstoreClientAPI {
|
||||
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
public class func createUser(body body: User?) -> RequestBuilder<Void> {
|
||||
public class func createUserWithRequestBuilder(body body: User?) -> RequestBuilder<Void> {
|
||||
let path = "/user"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
|
||||
@ -34,6 +66,38 @@ extension PetstoreClientAPI {
|
||||
return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Creates list of users with given input array
|
||||
|
||||
- parameter body: (body) List of user object
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
public class func createUsersWithArrayInput(body body: [User]?, completion: ((error: ErrorType?) -> Void)) {
|
||||
createUsersWithArrayInputWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(error: error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Creates list of users with given input array
|
||||
|
||||
- parameter body: (body) List of user object
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
public class func createUsersWithArrayInput(body body: [User]?) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pendingPromise()
|
||||
createUsersWithArrayInput(body: body) { error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill()
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Creates list of users with given input array
|
||||
@ -45,7 +109,7 @@ extension PetstoreClientAPI {
|
||||
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
public class func createUsersWithArrayInput(body body: [User]?) -> RequestBuilder<Void> {
|
||||
public class func createUsersWithArrayInputWithRequestBuilder(body body: [User]?) -> RequestBuilder<Void> {
|
||||
let path = "/user/createWithArray"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
|
||||
@ -56,6 +120,38 @@ extension PetstoreClientAPI {
|
||||
return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Creates list of users with given input array
|
||||
|
||||
- parameter body: (body) List of user object
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
public class func createUsersWithListInput(body body: [User]?, completion: ((error: ErrorType?) -> Void)) {
|
||||
createUsersWithListInputWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(error: error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Creates list of users with given input array
|
||||
|
||||
- parameter body: (body) List of user object
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
public class func createUsersWithListInput(body body: [User]?) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pendingPromise()
|
||||
createUsersWithListInput(body: body) { error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill()
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Creates list of users with given input array
|
||||
@ -67,7 +163,7 @@ extension PetstoreClientAPI {
|
||||
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
public class func createUsersWithListInput(body body: [User]?) -> RequestBuilder<Void> {
|
||||
public class func createUsersWithListInputWithRequestBuilder(body body: [User]?) -> RequestBuilder<Void> {
|
||||
let path = "/user/createWithList"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
|
||||
@ -78,6 +174,40 @@ extension PetstoreClientAPI {
|
||||
return requestBuilder.init(method: "POST", URLString: URLString, parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Logs user into the system
|
||||
|
||||
- parameter username: (query) The user name for login
|
||||
- parameter password: (query) The password for login in clear text
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
public class func loginUser(username username: String?, password: String?, completion: ((data: String?, error: ErrorType?) -> Void)) {
|
||||
loginUserWithRequestBuilder(username: username, password: password).execute { (response, error) -> Void in
|
||||
completion(data: response?.body, error: error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Logs user into the system
|
||||
|
||||
- parameter username: (query) The user name for login
|
||||
- parameter password: (query) The password for login in clear text
|
||||
- returns: Promise<String>
|
||||
*/
|
||||
public class func loginUser(username username: String?, password: String?) -> Promise<String> {
|
||||
let deferred = Promise<String>.pendingPromise()
|
||||
loginUser(username: username, password: password) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Logs user into the system
|
||||
@ -92,7 +222,7 @@ extension PetstoreClientAPI {
|
||||
|
||||
- returns: RequestBuilder<String>
|
||||
*/
|
||||
public class func loginUser(username username: String?, password: String?) -> RequestBuilder<String> {
|
||||
public class func loginUserWithRequestBuilder(username username: String?, password: String?) -> RequestBuilder<String> {
|
||||
let path = "/user/login"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
|
||||
@ -107,6 +237,36 @@ extension PetstoreClientAPI {
|
||||
return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Logs out current logged in user session
|
||||
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
public class func logoutUser(completion: ((error: ErrorType?) -> Void)) {
|
||||
logoutUserWithRequestBuilder().execute { (response, error) -> Void in
|
||||
completion(error: error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Logs out current logged in user session
|
||||
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
public class func logoutUser() -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pendingPromise()
|
||||
logoutUser() { error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill()
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Logs out current logged in user session
|
||||
@ -116,7 +276,7 @@ extension PetstoreClientAPI {
|
||||
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
public class func logoutUser() -> RequestBuilder<Void> {
|
||||
public class func logoutUserWithRequestBuilder() -> RequestBuilder<Void> {
|
||||
let path = "/user/logout"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
|
||||
@ -128,6 +288,38 @@ extension PetstoreClientAPI {
|
||||
return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Get user by user name
|
||||
|
||||
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
public class func getUserByName(username username: String, completion: ((data: User?, error: ErrorType?) -> Void)) {
|
||||
getUserByNameWithRequestBuilder(username: username).execute { (response, error) -> Void in
|
||||
completion(data: response?.body, error: error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Get user by user name
|
||||
|
||||
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
||||
- returns: Promise<User>
|
||||
*/
|
||||
public class func getUserByName(username username: String) -> Promise<User> {
|
||||
let deferred = Promise<User>.pendingPromise()
|
||||
getUserByName(username: username) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Get user by user name
|
||||
@ -149,7 +341,7 @@ extension PetstoreClientAPI {
|
||||
|
||||
- returns: RequestBuilder<User>
|
||||
*/
|
||||
public class func getUserByName(username username: String) -> RequestBuilder<User> {
|
||||
public class func getUserByNameWithRequestBuilder(username username: String) -> RequestBuilder<User> {
|
||||
var path = "/user/{username}"
|
||||
path = path.stringByReplacingOccurrencesOfString("{username}", withString: "\(username)", options: .LiteralSearch, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
@ -162,6 +354,40 @@ extension PetstoreClientAPI {
|
||||
return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Updated user
|
||||
|
||||
- parameter username: (path) name that need to be deleted
|
||||
- parameter body: (body) Updated user object
|
||||
- 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)) {
|
||||
updateUserWithRequestBuilder(username: username, body: body).execute { (response, error) -> Void in
|
||||
completion(error: error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Updated user
|
||||
|
||||
- parameter username: (path) name that need to be deleted
|
||||
- parameter body: (body) Updated user object
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
public class func updateUser(username username: String, body: User?) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pendingPromise()
|
||||
updateUser(username: username, body: body) { error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill()
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Updated user
|
||||
@ -174,7 +400,7 @@ extension PetstoreClientAPI {
|
||||
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
public class func updateUser(username username: String, body: User?) -> RequestBuilder<Void> {
|
||||
public class func updateUserWithRequestBuilder(username username: String, body: User?) -> RequestBuilder<Void> {
|
||||
var path = "/user/{username}"
|
||||
path = path.stringByReplacingOccurrencesOfString("{username}", withString: "\(username)", options: .LiteralSearch, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
@ -186,6 +412,38 @@ extension PetstoreClientAPI {
|
||||
return requestBuilder.init(method: "PUT", URLString: URLString, parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Delete user
|
||||
|
||||
- parameter username: (path) The name that needs to be deleted
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
public class func deleteUser(username username: String, completion: ((error: ErrorType?) -> Void)) {
|
||||
deleteUserWithRequestBuilder(username: username).execute { (response, error) -> Void in
|
||||
completion(error: error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Delete user
|
||||
|
||||
- parameter username: (path) The name that needs to be deleted
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
public class func deleteUser(username username: String) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pendingPromise()
|
||||
deleteUser(username: username) { error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill()
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Delete user
|
||||
@ -197,7 +455,7 @@ extension PetstoreClientAPI {
|
||||
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
public class func deleteUser(username username: String) -> RequestBuilder<Void> {
|
||||
public class func deleteUserWithRequestBuilder(username username: String) -> RequestBuilder<Void> {
|
||||
var path = "/user/{username}"
|
||||
path = path.stringByReplacingOccurrencesOfString("{username}", withString: "\(username)", options: .LiteralSearch, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
|
@ -35,7 +35,7 @@ class PetAPITests: XCTestCase {
|
||||
newPet.id = 1000
|
||||
newPet.name = "Fluffy"
|
||||
newPet.status = .Available
|
||||
PetstoreClientAPI.PetAPI.addPet(body: newPet).execute().then { response -> Void in
|
||||
PetstoreClientAPI.PetAPI.addPet(body: newPet).then {
|
||||
expectation.fulfill()
|
||||
}.always {
|
||||
// Noop for now
|
||||
@ -47,8 +47,7 @@ class PetAPITests: XCTestCase {
|
||||
|
||||
func test2GetPet() {
|
||||
let expectation = self.expectationWithDescription("testGetPet")
|
||||
PetstoreClientAPI.PetAPI.getPetById(petId: 1000).execute().then { response -> Void in
|
||||
let pet = response.body
|
||||
PetstoreClientAPI.PetAPI.getPetById(petId: 1000).then { pet -> Void in
|
||||
XCTAssert(pet.id == 1000, "invalid id")
|
||||
XCTAssert(pet.name == "Fluffy", "invalid name")
|
||||
expectation.fulfill()
|
||||
@ -62,7 +61,7 @@ class PetAPITests: XCTestCase {
|
||||
|
||||
func test3DeletePet() {
|
||||
let expectation = self.expectationWithDescription("testDeletePet")
|
||||
PetstoreClientAPI.PetAPI.deletePet(petId: 1000).execute().always { response -> Void in
|
||||
PetstoreClientAPI.PetAPI.deletePet(petId: 1000).always {
|
||||
// expectation.fulfill()
|
||||
}.always {
|
||||
// Noop for now
|
||||
|
@ -34,8 +34,7 @@ class StoreAPITests: XCTestCase {
|
||||
order.shipDate = NSDate()
|
||||
order.status = .Placed
|
||||
let expectation = self.expectationWithDescription("testPlaceOrder")
|
||||
PetstoreClientAPI.StoreAPI.placeOrder(body: order).execute().then { response -> Void in
|
||||
let order = response.body
|
||||
PetstoreClientAPI.StoreAPI.placeOrder(body: order).then { order -> Void in
|
||||
XCTAssert(order.id == 1000, "invalid id")
|
||||
XCTAssert(order.quantity == 10, "invalid quantity")
|
||||
XCTAssert(order.status == .Placed, "invalid status")
|
||||
@ -50,8 +49,7 @@ class StoreAPITests: XCTestCase {
|
||||
|
||||
func test2GetOrder() {
|
||||
let expectation = self.expectationWithDescription("testGetOrder")
|
||||
PetstoreClientAPI.StoreAPI.getOrderById(orderId: "1000").execute().then { response -> Void in
|
||||
let order = response.body
|
||||
PetstoreClientAPI.StoreAPI.getOrderById(orderId: "1000").then { order -> Void in
|
||||
XCTAssert(order.id == 1000, "invalid id")
|
||||
XCTAssert(order.quantity == 10, "invalid quantity")
|
||||
XCTAssert(order.status == .Placed, "invalid status")
|
||||
@ -66,7 +64,7 @@ class StoreAPITests: XCTestCase {
|
||||
|
||||
func test3DeleteOrder() {
|
||||
let expectation = self.expectationWithDescription("testDeleteOrder")
|
||||
PetstoreClientAPI.StoreAPI.deleteOrder(orderId: "1000").execute().then { response -> Void in
|
||||
PetstoreClientAPI.StoreAPI.deleteOrder(orderId: "1000").then {
|
||||
expectation.fulfill()
|
||||
}.always {
|
||||
// Noop for now
|
||||
|
@ -27,7 +27,7 @@ class UserAPITests: XCTestCase {
|
||||
|
||||
func testLogin() {
|
||||
let expectation = self.expectationWithDescription("testLogin")
|
||||
PetstoreClientAPI.UserAPI.loginUser(username: "swiftTester", password: "swift").execute().then { response -> Void in
|
||||
PetstoreClientAPI.UserAPI.loginUser(username: "swiftTester", password: "swift").then { _ -> Void in
|
||||
expectation.fulfill()
|
||||
}.always {
|
||||
// Noop for now
|
||||
@ -48,7 +48,7 @@ class UserAPITests: XCTestCase {
|
||||
|
||||
func testLogout() {
|
||||
let expectation = self.expectationWithDescription("testLogout")
|
||||
PetstoreClientAPI.UserAPI.logoutUser().execute().then { response -> Void in
|
||||
PetstoreClientAPI.UserAPI.logoutUser().then {
|
||||
expectation.fulfill()
|
||||
}.always {
|
||||
// Noop for now
|
||||
@ -79,7 +79,7 @@ class UserAPITests: XCTestCase {
|
||||
newUser.phone = "867-5309"
|
||||
newUser.username = "test@test.com"
|
||||
newUser.userStatus = 0
|
||||
PetstoreClientAPI.UserAPI.createUser(body: newUser).execute().then { response -> Void in
|
||||
PetstoreClientAPI.UserAPI.createUser(body: newUser).then {
|
||||
expectation.fulfill()
|
||||
}.always {
|
||||
// Noop for now
|
||||
@ -101,8 +101,7 @@ class UserAPITests: XCTestCase {
|
||||
|
||||
func test2GetUser() {
|
||||
let expectation = self.expectationWithDescription("testGetUser")
|
||||
PetstoreClientAPI.UserAPI.getUserByName(username: "test@test.com").execute().then { response -> Void in
|
||||
let user = response.body
|
||||
PetstoreClientAPI.UserAPI.getUserByName(username: "test@test.com").then {user -> Void in
|
||||
XCTAssert(user.userStatus == 0, "invalid userStatus")
|
||||
XCTAssert(user.email == "test@test.com", "invalid email")
|
||||
XCTAssert(user.firstName == "Test", "invalid firstName")
|
||||
@ -120,7 +119,7 @@ class UserAPITests: XCTestCase {
|
||||
|
||||
func test3DeleteUser() {
|
||||
let expectation = self.expectationWithDescription("testDeleteUser")
|
||||
PetstoreClientAPI.UserAPI.deleteUser(username: "test@test.com").execute().then { response -> Void in
|
||||
PetstoreClientAPI.UserAPI.deleteUser(username: "test@test.com").then {
|
||||
expectation.fulfill()
|
||||
}.always {
|
||||
// Noop for now
|
||||
|
Loading…
Reference in New Issue
Block a user