Make {{projectName}}API namespace for API classes optional

This commit is contained in:
hideya kawahara 2016-02-27 19:37:36 +09:00
parent ac3ab477d3
commit 9ee154c13a
9 changed files with 1561 additions and 1550 deletions

View File

@ -37,10 +37,12 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
public static final String POD_DESCRIPTION = "podDescription";
public static final String POD_SCREENSHOTS = "podScreenshots";
public static final String POD_DOCUMENTATION_URL = "podDocumentationURL";
public static final String SWIFT_USE_API_NAMESPACE = "swiftUseApiNamespace";
protected static final String LIBRARY_PROMISE_KIT = "PromiseKit";
protected static final String[] RESPONSE_LIBRARIES = { LIBRARY_PROMISE_KIT };
protected String projectName = "SwaggerClient";
protected boolean unwrapRequired;
protected boolean swiftUseApiNamespace;
protected String[] responseAs = new String[0];
protected String sourceFolder = "Classes" + File.separator + "Swaggers";
private static final Pattern PATH_PARAM_PATTERN = Pattern.compile("\\{[a-zA-Z_]+\\}");
@ -143,6 +145,7 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
cliOptions.add(new CliOption(POD_DESCRIPTION, "Description used for Podspec"));
cliOptions.add(new CliOption(POD_SCREENSHOTS, "Screenshots used for Podspec"));
cliOptions.add(new CliOption(POD_DOCUMENTATION_URL, "Documentation URL used for Podspec"));
cliOptions.add(new CliOption(SWIFT_USE_API_NAMESPACE, "Flag to make all the API classes inner-class of {{projectName}}API"));
}
@Override
@ -177,6 +180,12 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
additionalProperties.put("usePromiseKit", true);
}
// Setup swiftUseApiNamespace option, which makes all the API classes inner-class of {{projectName}}API
if (additionalProperties.containsKey(SWIFT_USE_API_NAMESPACE)) {
swiftUseApiNamespace = Boolean.parseBoolean(String.valueOf(additionalProperties.get(SWIFT_USE_API_NAMESPACE)));
}
additionalProperties.put(SWIFT_USE_API_NAMESPACE, swiftUseApiNamespace);
supportingFiles.add(new SupportingFile("Podspec.mustache", "", projectName + ".podspec"));
supportingFiles.add(new SupportingFile("Cartfile.mustache", "", "Cartfile"));
supportingFiles.add(new SupportingFile("APIHelper.mustache", sourceFolder, "APIHelper.swift"));

View File

@ -8,82 +8,88 @@
import Alamofire{{#usePromiseKit}}
import PromiseKit{{/usePromiseKit}}
{{#swiftUseApiNamespace}}
extension {{projectName}}API {
{{#description}}
/** {{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);
}
{{/swiftUseApiNamespace}}
{{#description}}
/** {{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}})
}
/**
{{#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
}
return deferred.promise
}
{{/usePromiseKit}}
/**
{{#summary}}
{{{summary}}}
{{/summary}}
- {{httpMethod}} {{path}}{{#notes}}
- {{{notes}}}{{/notes}}{{#subresourceOperation}}
- subresourceOperation: {{subresourceOperation}}{{/subresourceOperation}}{{#defaultResponse}}
- defaultResponse: {{defaultResponse}}{{/defaultResponse}}{{#authMethods}}
- {{#isBasic}}BASIC{{/isBasic}}{{#isOAuth}}OAuth{{/isOAuth}}{{#isApiKey}}API Key{{/isApiKey}}:
- type: {{type}}{{#keyParamName}} {{keyParamName}} {{#isKeyInQuery}}(QUERY){{/isKeyInQuery}}{{#isKeyInHeaer}}(HEADER){{/isKeyInHeaer}}{{/keyParamName}}
- name: {{name}}{{/authMethods}}{{#responseHeaders}}
- responseHeaders: {{responseHeaders}}{{/responseHeaders}}{{#examples}}
- examples: {{{examples}}}{{/examples}}{{#externalDocs}}
- externalDocs: {{externalDocs}}{{/externalDocs}}{{#hasParams}}
{{/hasParams}}{{#allParams}}
- parameter {{paramName}}: ({{#isFormParam}}form{{/isFormParam}}{{#isQueryParam}}query{{/isQueryParam}}{{#isPathParam}}path{{/isPathParam}}{{#isHeaderParam}}header{{/isHeaderParam}}{{#isBodyParam}}body{{/isBodyParam}}) {{description}}{{/allParams}}
/**
{{#summary}}
{{{summary}}}
{{/summary}}
- {{httpMethod}} {{path}}{{#notes}}
- {{{notes}}}{{/notes}}{{#subresourceOperation}}
- subresourceOperation: {{subresourceOperation}}{{/subresourceOperation}}{{#defaultResponse}}
- defaultResponse: {{defaultResponse}}{{/defaultResponse}}{{#authMethods}}
- {{#isBasic}}BASIC{{/isBasic}}{{#isOAuth}}OAuth{{/isOAuth}}{{#isApiKey}}API Key{{/isApiKey}}:
- type: {{type}}{{#keyParamName}} {{keyParamName}} {{#isKeyInQuery}}(QUERY){{/isKeyInQuery}}{{#isKeyInHeaer}}(HEADER){{/isKeyInHeaer}}{{/keyParamName}}
- name: {{name}}{{/authMethods}}{{#responseHeaders}}
- responseHeaders: {{responseHeaders}}{{/responseHeaders}}{{#examples}}
- examples: {{{examples}}}{{/examples}}{{#externalDocs}}
- externalDocs: {{externalDocs}}{{/externalDocs}}{{#hasParams}}
{{/hasParams}}{{#allParams}}
- parameter {{paramName}}: ({{#isFormParam}}form{{/isFormParam}}{{#isQueryParam}}query{{/isQueryParam}}{{#isPathParam}}path{{/isPathParam}}{{#isHeaderParam}}header{{/isHeaderParam}}{{#isBodyParam}}body{{/isBodyParam}}) {{description}}{{/allParams}}
- 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}}> {
{{^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
{{#bodyParam}}
let parameters = {{paramName}}{{^required}}?{{/required}}.encodeToJSON() as? [String:AnyObject]{{/bodyParam}}{{^bodyParam}}
let nillableParameters: [String:AnyObject?] = {{^queryParams}}{{^formParams}}[:]{{/formParams}}{{#formParams}}{{^secondaryParam}}[{{/secondaryParam}}
"{{paramName}}": {{paramName}}{{#hasMore}},{{/hasMore}}{{^hasMore}}
]{{/hasMore}}{{/formParams}}{{/queryParams}}{{#queryParams}}{{^secondaryParam}}[{{/secondaryParam}}
"{{paramName}}": {{paramName}}{{#hasMore}},{{/hasMore}}{{^hasMore}}
]{{/hasMore}}{{/queryParams}}
let parameters = APIHelper.rejectNil(nillableParameters){{/bodyParam}}
- 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}}> {
{{^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
{{#bodyParam}}
let parameters = {{paramName}}{{^required}}?{{/required}}.encodeToJSON() as? [String:AnyObject]{{/bodyParam}}{{^bodyParam}}
let nillableParameters: [String:AnyObject?] = {{^queryParams}}{{^formParams}}[:]{{/formParams}}{{#formParams}}{{^secondaryParam}}[{{/secondaryParam}}
"{{paramName}}": {{paramName}}{{#hasMore}},{{/hasMore}}{{^hasMore}}
]{{/hasMore}}{{/formParams}}{{/queryParams}}{{#queryParams}}{{^secondaryParam}}[{{/secondaryParam}}
"{{paramName}}": {{paramName}}{{#hasMore}},{{/hasMore}}{{^hasMore}}
]{{/hasMore}}{{/queryParams}}
let parameters = APIHelper.rejectNil(nillableParameters){{/bodyParam}}
let requestBuilder: RequestBuilder<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}>.Type = {{projectName}}API.requestBuilderFactory.getBuilder()
let requestBuilder: RequestBuilder<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}>.Type = {{projectName}}API.requestBuilderFactory.getBuilder()
return requestBuilder.init(method: "{{httpMethod}}", URLString: URLString, parameters: parameters, isBody: {{^queryParams}}{{^formParams}}true{{/formParams}}{{/queryParams}}{{#queryParams}}{{^secondaryParam}}false{{/secondaryParam}}{{/queryParams}}{{#formParams}}{{^secondaryParam}}false{{/secondaryParam}}{{/formParams}})
}
{{/operation}}
return requestBuilder.init(method: "{{httpMethod}}", URLString: URLString, parameters: parameters, isBody: {{^queryParams}}{{^formParams}}true{{/formParams}}{{/queryParams}}{{#queryParams}}{{^secondaryParam}}false{{/secondaryParam}}{{/queryParams}}{{#formParams}}{{^secondaryParam}}false{{/secondaryParam}}{{/formParams}})
}
{{/operation}}
}
{{#swiftUseApiNamespace}}
}
{{/swiftUseApiNamespace}}
{{/operations}}

View File

@ -25,6 +25,7 @@ public class SwiftOptionsProvider implements OptionsProvider {
public static final String POD_DESCRIPTION_VALUE = "podDescription";
public static final String POD_SCREENSHOTS_VALUE = "podScreenshots";
public static final String POD_DOCUMENTATION_URL_VALUE = "podDocumentationURL";
public static final String SWIFT_USE_API_NAMESPACE_VALUE = "swiftUseApiNamespace";
@Override
public String getLanguage() {
@ -50,6 +51,7 @@ public class SwiftOptionsProvider implements OptionsProvider {
.put(SwiftCodegen.POD_DESCRIPTION, POD_DESCRIPTION_VALUE)
.put(SwiftCodegen.POD_SCREENSHOTS, POD_SCREENSHOTS_VALUE)
.put(SwiftCodegen.POD_DOCUMENTATION_URL, POD_DOCUMENTATION_URL_VALUE)
.put(SwiftCodegen.SWIFT_USE_API_NAMESPACE, SWIFT_USE_API_NAMESPACE_VALUE)
.build();
}

View File

@ -8,307 +8,305 @@
import Alamofire
import PromiseKit
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);
}
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
- GET /store/inventory
- Returns a map of status codes to quantities
- API Key:
- type: apiKey api_key
- name: api_key
- examples: [{example={
"key" : 123
}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}]
- examples: [{example={
"key" : 123
}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}]
- returns: RequestBuilder<[String:Int]>
*/
public class func getInventoryWithRequestBuilder() -> RequestBuilder<[String:Int]> {
let path = "/store/inventory"
let URLString = PetstoreClientAPI.basePath + path
let nillableParameters: [String:AnyObject?] = [:]
let parameters = APIHelper.rejectNil(nillableParameters)
let requestBuilder: RequestBuilder<[String:Int]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
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,
"complete" : true,
"status" : "aeiou",
"quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
}, contentType=application/json}, {example=<Order>
<id>123456</id>
<petId>123456</petId>
<quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status>
<complete>true</complete>
</Order>, contentType=application/xml}]
- examples: [{example={
"id" : 123456789,
"petId" : 123456789,
"complete" : true,
"status" : "aeiou",
"quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
}, contentType=application/json}, {example=<Order>
<id>123456</id>
<petId>123456</petId>
<quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status>
<complete>true</complete>
</Order>, contentType=application/xml}]
- parameter body: (body) order placed for purchasing the pet
- returns: RequestBuilder<Order>
*/
public class func placeOrderWithRequestBuilder(body body: Order?) -> RequestBuilder<Order> {
let path = "/store/order"
let URLString = PetstoreClientAPI.basePath + path
let parameters = body?.encodeToJSON() as? [String:AnyObject]
let requestBuilder: RequestBuilder<Order>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
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,
"complete" : true,
"status" : "aeiou",
"quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
}, contentType=application/json}, {example=<Order>
<id>123456</id>
<petId>123456</petId>
<quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status>
<complete>true</complete>
</Order>, contentType=application/xml}]
- examples: [{example={
"id" : 123456789,
"petId" : 123456789,
"complete" : true,
"status" : "aeiou",
"quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
}, contentType=application/json}, {example=<Order>
<id>123456</id>
<petId>123456</petId>
<quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status>
<complete>true</complete>
</Order>, contentType=application/xml}]
- parameter orderId: (path) ID of pet that needs to be fetched
- returns: 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
let nillableParameters: [String:AnyObject?] = [:]
let parameters = APIHelper.rejectNil(nillableParameters)
let requestBuilder: RequestBuilder<Order>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
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
- DELETE /store/order/{orderId}
- For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
- parameter orderId: (path) ID of the order that needs to be deleted
- returns: 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
let nillableParameters: [String:AnyObject?] = [:]
let parameters = APIHelper.rejectNil(nillableParameters)
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
return requestBuilder.init(method: "DELETE", URLString: URLString, parameters: parameters, isBody: true)
}
}
/**
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
- GET /store/inventory
- Returns a map of status codes to quantities
- API Key:
- type: apiKey api_key
- name: api_key
- examples: [{example={
"key" : 123
}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}]
- examples: [{example={
"key" : 123
}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}]
- returns: RequestBuilder<[String:Int]>
*/
public class func getInventoryWithRequestBuilder() -> RequestBuilder<[String:Int]> {
let path = "/store/inventory"
let URLString = PetstoreClientAPI.basePath + path
let nillableParameters: [String:AnyObject?] = [:]
let parameters = APIHelper.rejectNil(nillableParameters)
let requestBuilder: RequestBuilder<[String:Int]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
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,
"complete" : true,
"status" : "aeiou",
"quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
}, contentType=application/json}, {example=<Order>
<id>123456</id>
<petId>123456</petId>
<quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status>
<complete>true</complete>
</Order>, contentType=application/xml}]
- examples: [{example={
"id" : 123456789,
"petId" : 123456789,
"complete" : true,
"status" : "aeiou",
"quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
}, contentType=application/json}, {example=<Order>
<id>123456</id>
<petId>123456</petId>
<quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status>
<complete>true</complete>
</Order>, contentType=application/xml}]
- parameter body: (body) order placed for purchasing the pet
- returns: RequestBuilder<Order>
*/
public class func placeOrderWithRequestBuilder(body body: Order?) -> RequestBuilder<Order> {
let path = "/store/order"
let URLString = PetstoreClientAPI.basePath + path
let parameters = body?.encodeToJSON() as? [String:AnyObject]
let requestBuilder: RequestBuilder<Order>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
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,
"complete" : true,
"status" : "aeiou",
"quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
}, contentType=application/json}, {example=<Order>
<id>123456</id>
<petId>123456</petId>
<quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status>
<complete>true</complete>
</Order>, contentType=application/xml}]
- examples: [{example={
"id" : 123456789,
"petId" : 123456789,
"complete" : true,
"status" : "aeiou",
"quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
}, contentType=application/json}, {example=<Order>
<id>123456</id>
<petId>123456</petId>
<quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status>
<complete>true</complete>
</Order>, contentType=application/xml}]
- parameter orderId: (path) ID of pet that needs to be fetched
- returns: 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
let nillableParameters: [String:AnyObject?] = [:]
let parameters = APIHelper.rejectNil(nillableParameters)
let requestBuilder: RequestBuilder<Order>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
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
- DELETE /store/order/{orderId}
- For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
- parameter orderId: (path) ID of the order that needs to be deleted
- returns: 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
let nillableParameters: [String:AnyObject?] = [:]
let parameters = APIHelper.rejectNil(nillableParameters)
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
return requestBuilder.init(method: "DELETE", URLString: URLString, parameters: parameters, isBody: true)
}
}

View File

@ -8,325 +8,324 @@
import Alamofire
import PromiseKit
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);
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
- 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
- POST /user
- This can only be done by the logged in user.
- parameter body: (body) Created user object
- returns: RequestBuilder<Void>
*/
public class func createUserWithRequestBuilder(body body: User?) -> RequestBuilder<Void> {
let path = "/user"
let URLString = PetstoreClientAPI.basePath + path
let parameters = body?.encodeToJSON() as? [String:AnyObject]
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
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);
}
}
/**
Create user
- POST /user
- This can only be done by the logged in user.
- parameter body: (body) Created user object
- returns: RequestBuilder<Void>
*/
public class func createUserWithRequestBuilder(body body: User?) -> RequestBuilder<Void> {
let path = "/user"
let URLString = PetstoreClientAPI.basePath + path
let parameters = body?.encodeToJSON() as? [String:AnyObject]
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
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
- 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
- POST /user/createWithArray
-
- parameter body: (body) List of user object
- returns: RequestBuilder<Void>
*/
public class func createUsersWithArrayInputWithRequestBuilder(body body: [User]?) -> RequestBuilder<Void> {
let path = "/user/createWithArray"
let URLString = PetstoreClientAPI.basePath + path
let parameters = body?.encodeToJSON() as? [String:AnyObject]
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
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
- POST /user/createWithArray
-
- parameter body: (body) List of user object
- returns: RequestBuilder<Void>
*/
public class func createUsersWithArrayInputWithRequestBuilder(body body: [User]?) -> RequestBuilder<Void> {
let path = "/user/createWithArray"
let URLString = PetstoreClientAPI.basePath + path
let parameters = body?.encodeToJSON() as? [String:AnyObject]
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
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
- 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
- POST /user/createWithList
-
- parameter body: (body) List of user object
- returns: RequestBuilder<Void>
*/
public class func createUsersWithListInputWithRequestBuilder(body body: [User]?) -> RequestBuilder<Void> {
let path = "/user/createWithList"
let URLString = PetstoreClientAPI.basePath + path
let parameters = body?.encodeToJSON() as? [String:AnyObject]
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
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);
}
}
/**
Creates list of users with given input array
- POST /user/createWithList
-
- parameter body: (body) List of user object
- returns: RequestBuilder<Void>
*/
public class func createUsersWithListInputWithRequestBuilder(body body: [User]?) -> RequestBuilder<Void> {
let path = "/user/createWithList"
let URLString = PetstoreClientAPI.basePath + path
let parameters = body?.encodeToJSON() as? [String:AnyObject]
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
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
- 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
- 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}]
- parameter username: (query) The user name for login
- parameter password: (query) The password for login in clear text
- returns: RequestBuilder<String>
*/
public class func loginUserWithRequestBuilder(username username: String?, password: String?) -> RequestBuilder<String> {
let path = "/user/login"
let URLString = PetstoreClientAPI.basePath + path
let nillableParameters: [String:AnyObject?] = [
"username": username,
"password": password
]
let parameters = APIHelper.rejectNil(nillableParameters)
let requestBuilder: RequestBuilder<String>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
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 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}]
- parameter username: (query) The user name for login
- parameter password: (query) The password for login in clear text
- returns: RequestBuilder<String>
*/
public class func loginUserWithRequestBuilder(username username: String?, password: String?) -> RequestBuilder<String> {
let path = "/user/login"
let URLString = PetstoreClientAPI.basePath + path
let nillableParameters: [String:AnyObject?] = [
"username": username,
"password": password
]
let parameters = APIHelper.rejectNil(nillableParameters)
let requestBuilder: RequestBuilder<String>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
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
- 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
- GET /user/logout
-
- returns: RequestBuilder<Void>
*/
public class func logoutUserWithRequestBuilder() -> RequestBuilder<Void> {
let path = "/user/logout"
let URLString = PetstoreClientAPI.basePath + path
let nillableParameters: [String:AnyObject?] = [:]
let parameters = APIHelper.rejectNil(nillableParameters)
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
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);
}
}
/**
Logs out current logged in user session
- GET /user/logout
-
- returns: RequestBuilder<Void>
*/
public class func logoutUserWithRequestBuilder() -> RequestBuilder<Void> {
let path = "/user/logout"
let URLString = PetstoreClientAPI.basePath + path
let nillableParameters: [String:AnyObject?] = [:]
let parameters = APIHelper.rejectNil(nillableParameters)
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
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
- 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
- GET /user/{username}
-
- examples: [{example={
/**
Get user by user name
- GET /user/{username}
-
- examples: [{example={
"id" : 1,
"username" : "johnp",
"firstName" : "John",
@ -336,137 +335,136 @@ extension PetstoreClientAPI {
"phone" : "0123456789",
"userStatus" : 0
}, contentType=application/json}]
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
- returns: RequestBuilder<User>
*/
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
let nillableParameters: [String:AnyObject?] = [:]
let parameters = APIHelper.rejectNil(nillableParameters)
- returns: 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
let nillableParameters: [String:AnyObject?] = [:]
let parameters = APIHelper.rejectNil(nillableParameters)
let requestBuilder: RequestBuilder<User>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
let requestBuilder: RequestBuilder<User>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
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
- PUT /user/{username}
- This can only be done by the logged in user.
- parameter username: (path) name that need to be deleted
- parameter body: (body) Updated user object
- returns: 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
let parameters = body?.encodeToJSON() as? [String:AnyObject]
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
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
- DELETE /user/{username}
- This can only be done by the logged in user.
- parameter username: (path) The name that needs to be deleted
- returns: 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
let nillableParameters: [String:AnyObject?] = [:]
let parameters = APIHelper.rejectNil(nillableParameters)
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
return requestBuilder.init(method: "DELETE", URLString: URLString, parameters: parameters, isBody: true)
}
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
- PUT /user/{username}
- This can only be done by the logged in user.
- parameter username: (path) name that need to be deleted
- parameter body: (body) Updated user object
- returns: 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
let parameters = body?.encodeToJSON() as? [String:AnyObject]
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
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
- DELETE /user/{username}
- This can only be done by the logged in user.
- parameter username: (path) The name that needs to be deleted
- returns: 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
let nillableParameters: [String:AnyObject?] = [:]
let parameters = APIHelper.rejectNil(nillableParameters)
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
return requestBuilder.init(method: "DELETE", URLString: URLString, parameters: parameters, isBody: true)
}
}

View File

@ -35,7 +35,7 @@ class PetAPITests: XCTestCase {
newPet.id = 1000
newPet.name = "Fluffy"
newPet.status = .Available
PetstoreClientAPI.PetAPI.addPet(body: newPet).then {
PetAPI.addPet(body: newPet).then {
expectation.fulfill()
}.always {
// Noop for now
@ -47,7 +47,7 @@ class PetAPITests: XCTestCase {
func test2GetPet() {
let expectation = self.expectationWithDescription("testGetPet")
PetstoreClientAPI.PetAPI.getPetById(petId: 1000).then { pet -> Void in
PetAPI.getPetById(petId: 1000).then { pet -> Void in
XCTAssert(pet.id == 1000, "invalid id")
XCTAssert(pet.name == "Fluffy", "invalid name")
expectation.fulfill()
@ -61,7 +61,7 @@ class PetAPITests: XCTestCase {
func test3DeletePet() {
let expectation = self.expectationWithDescription("testDeletePet")
PetstoreClientAPI.PetAPI.deletePet(petId: 1000).always {
PetAPI.deletePet(petId: 1000).always {
// expectation.fulfill()
}.always {
// Noop for now

View File

@ -34,7 +34,7 @@ class StoreAPITests: XCTestCase {
order.shipDate = NSDate()
order.status = .Placed
let expectation = self.expectationWithDescription("testPlaceOrder")
PetstoreClientAPI.StoreAPI.placeOrder(body: order).then { order -> Void in
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")
@ -49,7 +49,7 @@ class StoreAPITests: XCTestCase {
func test2GetOrder() {
let expectation = self.expectationWithDescription("testGetOrder")
PetstoreClientAPI.StoreAPI.getOrderById(orderId: "1000").then { order -> Void in
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")
@ -64,7 +64,7 @@ class StoreAPITests: XCTestCase {
func test3DeleteOrder() {
let expectation = self.expectationWithDescription("testDeleteOrder")
PetstoreClientAPI.StoreAPI.deleteOrder(orderId: "1000").then {
StoreAPI.deleteOrder(orderId: "1000").then {
expectation.fulfill()
}.always {
// Noop for now

View File

@ -27,7 +27,7 @@ class UserAPITests: XCTestCase {
func testLogin() {
let expectation = self.expectationWithDescription("testLogin")
PetstoreClientAPI.UserAPI.loginUser(username: "swiftTester", password: "swift").then { _ -> Void in
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().then {
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).then {
UserAPI.createUser(body: newUser).then {
expectation.fulfill()
}.always {
// Noop for now
@ -101,7 +101,7 @@ class UserAPITests: XCTestCase {
func test2GetUser() {
let expectation = self.expectationWithDescription("testGetUser")
PetstoreClientAPI.UserAPI.getUserByName(username: "test@test.com").then {user -> Void in
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")
@ -119,7 +119,7 @@ class UserAPITests: XCTestCase {
func test3DeleteUser() {
let expectation = self.expectationWithDescription("testDeleteUser")
PetstoreClientAPI.UserAPI.deleteUser(username: "test@test.com").then {
UserAPI.deleteUser(username: "test@test.com").then {
expectation.fulfill()
}.always {
// Noop for now