diff --git a/samples/client/petstore/akka-scala/pom.xml b/samples/client/petstore/akka-scala/pom.xml index a047ad86cc0..a6e81fb75f4 100644 --- a/samples/client/petstore/akka-scala/pom.xml +++ b/samples/client/petstore/akka-scala/pom.xml @@ -217,7 +217,7 @@ 2.3.9 1.2 2.2 - 1.5.0 + 1.5.4 1.0.0 4.8.1 diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala index 591d055dad6..7decd51b03c 100644 --- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala @@ -11,18 +11,18 @@ object PetApi { /** * * Expected answers: - * code 405 : (Validation exception) - * code 404 : (Pet not found) * code 400 : (Invalid ID supplied) + * code 404 : (Pet not found) + * code 405 : (Validation exception) * * @param body Pet object that needs to be added to the store */ def updatePet(body: Option[Pet] = None): ApiRequest[Unit] = ApiRequest[Unit](ApiMethods.PUT, "http://petstore.swagger.io/v2", "/pet", "application/json") .withBody(body) - .withErrorResponse[Unit](405) - .withErrorResponse[Unit](404) .withErrorResponse[Unit](400) + .withErrorResponse[Unit](404) + .withErrorResponse[Unit](405) /** * @@ -70,9 +70,9 @@ object PetApi { * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * * Expected answers: - * code 404 : (Pet not found) * code 200 : Pet (successful operation) * code 400 : (Invalid ID supplied) + * code 404 : (Pet not found) * * Available security schemes: * api_key (apiKey) @@ -83,9 +83,9 @@ object PetApi { ApiRequest[Pet](ApiMethods.GET, "http://petstore.swagger.io/v2", "/pet/{petId}", "application/json") .withApiKey(apiKey, "api_key", HEADER) .withPathParam("petId", petId) - .withErrorResponse[Unit](404) .withSuccessResponse[Pet](200) .withErrorResponse[Unit](400) + .withErrorResponse[Unit](404) /** * diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/StoreApi.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/StoreApi.scala index 686e85e105d..f3ab28da05f 100644 --- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/StoreApi.scala +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/StoreApi.scala @@ -39,33 +39,33 @@ object StoreApi { * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * * Expected answers: - * code 404 : (Order not found) * code 200 : Order (successful operation) * code 400 : (Invalid ID supplied) + * code 404 : (Order not found) * * @param orderId ID of pet that needs to be fetched */ def getOrderById(orderId: String): ApiRequest[Order] = ApiRequest[Order](ApiMethods.GET, "http://petstore.swagger.io/v2", "/store/order/{orderId}", "application/json") .withPathParam("orderId", orderId) - .withErrorResponse[Unit](404) .withSuccessResponse[Order](200) .withErrorResponse[Unit](400) + .withErrorResponse[Unit](404) /** * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * * Expected answers: - * code 404 : (Order not found) * code 400 : (Invalid ID supplied) + * code 404 : (Order not found) * * @param orderId ID of the order that needs to be deleted */ def deleteOrder(orderId: String): ApiRequest[Unit] = ApiRequest[Unit](ApiMethods.DELETE, "http://petstore.swagger.io/v2", "/store/order/{orderId}", "application/json") .withPathParam("orderId", orderId) - .withErrorResponse[Unit](404) .withErrorResponse[Unit](400) + .withErrorResponse[Unit](404) diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/UserApi.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/UserApi.scala index 4c2ab10e9e7..b759a799e3d 100644 --- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/UserApi.scala +++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/UserApi.scala @@ -72,25 +72,25 @@ object UserApi { /** * * Expected answers: - * code 404 : (User not found) * code 200 : User (successful operation) * code 400 : (Invalid username supplied) + * code 404 : (User not found) * - * @param username The name that needs to be fetched. Use user1 for testing. + * @param username The name that needs to be fetched. Use user1 for testing. */ def getUserByName(username: String): ApiRequest[User] = ApiRequest[User](ApiMethods.GET, "http://petstore.swagger.io/v2", "/user/{username}", "application/json") .withPathParam("username", username) - .withErrorResponse[Unit](404) .withSuccessResponse[User](200) .withErrorResponse[Unit](400) + .withErrorResponse[Unit](404) /** * This can only be done by the logged in user. * * Expected answers: - * code 404 : (User not found) * code 400 : (Invalid user supplied) + * code 404 : (User not found) * * @param username name that need to be deleted * @param body Updated user object @@ -99,23 +99,23 @@ object UserApi { ApiRequest[Unit](ApiMethods.PUT, "http://petstore.swagger.io/v2", "/user/{username}", "application/json") .withBody(body) .withPathParam("username", username) - .withErrorResponse[Unit](404) .withErrorResponse[Unit](400) + .withErrorResponse[Unit](404) /** * This can only be done by the logged in user. * * Expected answers: - * code 404 : (User not found) * code 400 : (Invalid username supplied) + * code 404 : (User not found) * * @param username The name that needs to be deleted */ def deleteUser(username: String): ApiRequest[Unit] = ApiRequest[Unit](ApiMethods.DELETE, "http://petstore.swagger.io/v2", "/user/{username}", "application/json") .withPathParam("username", username) - .withErrorResponse[Unit](404) .withErrorResponse[Unit](400) + .withErrorResponse[Unit](404) diff --git a/samples/client/petstore/android-java/pom.xml b/samples/client/petstore/android-java/pom.xml index 639000ecc6d..f9c620b7528 100644 --- a/samples/client/petstore/android-java/pom.xml +++ b/samples/client/petstore/android-java/pom.xml @@ -145,7 +145,7 @@ - 1.5.0 + 1.5.4 2.3.1 4.8.1 1.0.0 diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java index a16a745c7f8..4c1bf7b1a3d 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java @@ -316,7 +316,7 @@ public class UserApi { /** * Get user by user name * - * @param username The name that needs to be fetched. Use user1 for testing. + * @param username The name that needs to be fetched. Use user1 for testing. * @return User */ public User getUserByName (String username) throws ApiException { diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Pet.java index 90a840e6e42..20865ad5434 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Pet.java @@ -18,9 +18,9 @@ public class Pet { @SerializedName("name") private String name = null; @SerializedName("photoUrls") - private List photoUrls = new ArrayList() ; + private List photoUrls = null; @SerializedName("tags") - private List tags = new ArrayList() ; + private List tags = null; public enum StatusEnum { available, pending, sold, }; diff --git a/samples/client/petstore/async-scala/src/main/scala/io/swagger/client/api/PetApi.scala b/samples/client/petstore/async-scala/src/main/scala/io/swagger/client/api/PetApi.scala index 4b6a2b155d9..84b6ba4c7ea 100644 --- a/samples/client/petstore/async-scala/src/main/scala/io/swagger/client/api/PetApi.scala +++ b/samples/client/petstore/async-scala/src/main/scala/io/swagger/client/api/PetApi.scala @@ -145,8 +145,9 @@ class PetApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(c } - def deletePet(apiKey: Option[String] = None, - petId: Long)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = { + def deletePet(petId: Long, + apiKey: Option[String] = None + )(implicit reader: ClientResponseReader[Unit]): Future[Unit] = { // create path and map variables val path = (addFmt("/pet/{petId}") replaceAll ("\\{" + "petId" + "\\}",petId.toString)) diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/PetApi.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/PetApi.pm index bf085889e79..19a3d88b299 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/PetApi.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/PetApi.pm @@ -387,8 +387,8 @@ sub update_pet_with_form { # # Deletes a pet # -# @param string $api_key (optional) # @param int $pet_id Pet id to delete (required) +# @param string $api_key (optional) # @return void # sub delete_pet { diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/UserApi.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/UserApi.pm index 4c6e293aaaa..e1088a0839e 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/UserApi.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/UserApi.pm @@ -305,7 +305,7 @@ sub logout_user { # # Get user by user name # -# @param string $username The name that needs to be fetched. Use user1 for testing. (required) +# @param string $username The name that needs to be fetched. Use user1 for testing. (required) # @return User # sub get_user_by_name { diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php index e8dea97be93..cb0df4e8af0 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -424,9 +424,6 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } - - //TODO support oauth - $apiKey = $this->apiClient->getApiKeyWithPrefix('api_key'); if (isset($apiKey)) { $headerParams['api_key'] = $apiKey; @@ -434,6 +431,9 @@ class PetApi + + //TODO support oauth + // make the API Call try { diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php index efdc1c896ab..0d281b9d1fa 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php @@ -193,7 +193,7 @@ class ObjectSerializer $deserialized = $values; } elseif ($class === '\DateTime') { $deserialized = new \DateTime($data); - } elseif (in_array($class, array('void', 'bool', 'string', 'double', 'byte', 'mixed', 'integer', 'float', 'int', 'DateTime', 'number', 'boolean', 'object'))) { + } elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) { settype($data, $class); $deserialized = $data; } elseif ($class === '\SplFileObject') { diff --git a/samples/client/petstore/python/swagger_client/__init__.py b/samples/client/petstore/python/swagger_client/__init__.py index 6e7b59f36fd..f61c5d55262 100644 --- a/samples/client/petstore/python/swagger_client/__init__.py +++ b/samples/client/petstore/python/swagger_client/__init__.py @@ -9,8 +9,8 @@ from .models.order import Order # import apis into sdk package from .apis.user_api import UserApi -from .apis.store_api import StoreApi from .apis.pet_api import PetApi +from .apis.store_api import StoreApi # import ApiClient from .api_client import ApiClient diff --git a/samples/client/petstore/python/swagger_client/apis/__init__.py b/samples/client/petstore/python/swagger_client/apis/__init__.py index c0e09458f95..592a56e282d 100644 --- a/samples/client/petstore/python/swagger_client/apis/__init__.py +++ b/samples/client/petstore/python/swagger_client/apis/__init__.py @@ -2,5 +2,5 @@ from __future__ import absolute_import # import apis into api package from .user_api import UserApi -from .store_api import StoreApi from .pet_api import PetApi +from .store_api import StoreApi diff --git a/samples/client/petstore/python/swagger_client/apis/pet_api.py b/samples/client/petstore/python/swagger_client/apis/pet_api.py index b162cc534c3..ad053a7d72d 100644 --- a/samples/client/petstore/python/swagger_client/apis/pet_api.py +++ b/samples/client/petstore/python/swagger_client/apis/pet_api.py @@ -409,7 +409,7 @@ class PetApi(object): select_header_content_type([]) # Authentication setting - auth_settings = ['petstore_auth', 'api_key'] + auth_settings = ['api_key', 'petstore_auth'] response = self.api_client.call_api(resource_path, method, path_params, diff --git a/samples/client/petstore/ruby/lib/petstore.rb b/samples/client/petstore/ruby/lib/petstore.rb index c13e99f29fc..61640d687ac 100644 --- a/samples/client/petstore/ruby/lib/petstore.rb +++ b/samples/client/petstore/ruby/lib/petstore.rb @@ -14,8 +14,8 @@ require 'petstore/models/order' # APIs require 'petstore/api/user_api' -require 'petstore/api/store_api' require 'petstore/api/pet_api' +require 'petstore/api/store_api' module Petstore class << self diff --git a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb index a9d30a00147..4b956aeadcc 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb @@ -237,7 +237,7 @@ module Petstore post_body = nil - auth_names = ['petstore_auth', 'api_key'] + auth_names = ['api_key', 'petstore_auth'] result = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, diff --git a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb index f4672e2a358..7f546330f3a 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb @@ -248,7 +248,7 @@ module Petstore # Get user by user name # - # @param username The name that needs to be fetched. Use user1 for testing. + # @param username The name that needs to be fetched. Use user1 for testing. # @param [Hash] opts the optional parameters # @return [User] def get_user_by_name(username, opts = {}) diff --git a/samples/client/petstore/scala/pom.xml b/samples/client/petstore/scala/pom.xml index 9f39f4e45ce..ff38920fcdd 100644 --- a/samples/client/petstore/scala/pom.xml +++ b/samples/client/petstore/scala/pom.xml @@ -210,7 +210,7 @@ 1.2 2.2 1.19 - 1.5.0 + 1.5.4 1.0.5 1.0.0 2.4.2 diff --git a/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/PetApi.scala b/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/PetApi.scala index 0d0b3c83ed2..a11cab9211b 100644 --- a/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/PetApi.scala +++ b/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/PetApi.scala @@ -325,11 +325,11 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", /** * Deletes a pet * - * @param apiKey * @param petId Pet id to delete + * @param apiKey * @return void */ - def deletePet (apiKey: String, petId: Long) = { + def deletePet (petId: Long, apiKey: String) = { // create path and map variables val path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId)) diff --git a/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/UserApi.scala b/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/UserApi.scala index 5a7b38f620a..802cf01c25b 100644 --- a/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/UserApi.scala +++ b/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/UserApi.scala @@ -263,7 +263,7 @@ class UserApi(val defBasePath: String = "http://petstore.swagger.io/v2", /** * Get user by user name * - * @param username The name that needs to be fetched. Use user1 for testing. + * @param username The name that needs to be fetched. Use user1 for testing. * @return User */ def getUserByName (username: String) : Option[User] = { diff --git a/samples/client/petstore/typescript-angular/API/Client/api.d.ts b/samples/client/petstore/typescript-angular/API/Client/api.d.ts index 46123a07ad3..19c60623dc9 100644 --- a/samples/client/petstore/typescript-angular/API/Client/api.d.ts +++ b/samples/client/petstore/typescript-angular/API/Client/api.d.ts @@ -5,5 +5,5 @@ /// /// -/// /// +/// diff --git a/samples/client/petstore/typescript-node/api.ts b/samples/client/petstore/typescript-node/api.ts index 742169a608e..148782a4000 100644 --- a/samples/client/petstore/typescript-node/api.ts +++ b/samples/client/petstore/typescript-node/api.ts @@ -149,6 +149,7 @@ export class UserApi { var headerParams: any = {}; var formParams: any = {}; + var useFormData = false; var deferred = promise.defer<{ response: http.ClientResponse; }>(); @@ -194,6 +195,7 @@ export class UserApi { var headerParams: any = {}; var formParams: any = {}; + var useFormData = false; var deferred = promise.defer<{ response: http.ClientResponse; }>(); @@ -239,6 +241,7 @@ export class UserApi { var headerParams: any = {}; var formParams: any = {}; + var useFormData = false; var deferred = promise.defer<{ response: http.ClientResponse; }>(); @@ -284,6 +287,7 @@ export class UserApi { var headerParams: any = {}; var formParams: any = {}; + if (username !== undefined) { queryParameters['username'] = username; } @@ -336,6 +340,7 @@ export class UserApi { var headerParams: any = {}; var formParams: any = {}; + var useFormData = false; var deferred = promise.defer<{ response: http.ClientResponse; }>(); @@ -382,6 +387,7 @@ export class UserApi { var headerParams: any = {}; var formParams: any = {}; + // verify required parameter 'username' is set if (!username) { throw new Error('Missing required parameter username when calling getUserByName'); @@ -433,6 +439,7 @@ export class UserApi { var headerParams: any = {}; var formParams: any = {}; + // verify required parameter 'username' is set if (!username) { throw new Error('Missing required parameter username when calling updateUser'); @@ -485,6 +492,7 @@ export class UserApi { var headerParams: any = {}; var formParams: any = {}; + // verify required parameter 'username' is set if (!username) { throw new Error('Missing required parameter username when calling deleteUser'); @@ -527,224 +535,6 @@ export class UserApi { return deferred.promise; } } -export class StoreApi { - private basePath = 'http://petstore.swagger.io/v2'; - public authentications = { - 'default': new VoidAuth(), - 'api_key': new ApiKeyAuth('header', 'api_key'), - 'petstore_auth': new OAuth(), - } - - constructor(url: string, basePath?: string); - constructor(private url: string, basePathOrUsername: string, password?: string, basePath?: string) { - if (password) { - if (basePath) { - this.basePath = basePath; - } - } else { - if (basePathOrUsername) { - this.basePath = basePathOrUsername - } - } - } - - set apiKey(key: string) { - this.authentications.api_key.apiKey = key; - } - - public getInventory () : Promise<{ response: http.ClientResponse; body: { [key: string]: number; }; }> { - var path = this.url + this.basePath + '/store/inventory'; - - var queryParameters: any = {}; - var headerParams: any = {}; - var formParams: any = {}; - - var useFormData = false; - - var deferred = promise.defer<{ response: http.ClientResponse; body: { [key: string]: number; }; }>(); - - var requestOptions: request.Options = { - method: 'GET', - qs: queryParameters, - headers: headerParams, - uri: path, - json: true, - } - - this.authentications.api_key.applyToRequest(requestOptions); - - this.authentications.default.applyToRequest(requestOptions); - - if (Object.keys(formParams).length) { - if (useFormData) { - (requestOptions).formData = formParams; - } else { - requestOptions.form = formParams; - } - } - - request(requestOptions, (error, response, body) => { - if (error) { - deferred.reject(error); - } else { - if (response.statusCode >= 200 && response.statusCode <= 299) { - deferred.resolve({ response: response, body: body }); - } else { - deferred.reject({ response: response, body: body }); - } - } - }); - - return deferred.promise; - } - - public placeOrder (body?: Order) : Promise<{ response: http.ClientResponse; body: Order; }> { - var path = this.url + this.basePath + '/store/order'; - - var queryParameters: any = {}; - var headerParams: any = {}; - var formParams: any = {}; - - var useFormData = false; - - var deferred = promise.defer<{ response: http.ClientResponse; body: Order; }>(); - - var requestOptions: request.Options = { - method: 'POST', - qs: queryParameters, - headers: headerParams, - uri: path, - json: true, - body: body, - } - - this.authentications.default.applyToRequest(requestOptions); - - if (Object.keys(formParams).length) { - if (useFormData) { - (requestOptions).formData = formParams; - } else { - requestOptions.form = formParams; - } - } - - request(requestOptions, (error, response, body) => { - if (error) { - deferred.reject(error); - } else { - if (response.statusCode >= 200 && response.statusCode <= 299) { - deferred.resolve({ response: response, body: body }); - } else { - deferred.reject({ response: response, body: body }); - } - } - }); - - return deferred.promise; - } - - public getOrderById (orderId: string) : Promise<{ response: http.ClientResponse; body: Order; }> { - var path = this.url + this.basePath + '/store/order/{orderId}'; - - path = path.replace('{' + 'orderId' + '}', String(orderId)); - - var queryParameters: any = {}; - var headerParams: any = {}; - var formParams: any = {}; - - // verify required parameter 'orderId' is set - if (!orderId) { - throw new Error('Missing required parameter orderId when calling getOrderById'); - } - - var useFormData = false; - - var deferred = promise.defer<{ response: http.ClientResponse; body: Order; }>(); - - var requestOptions: request.Options = { - method: 'GET', - qs: queryParameters, - headers: headerParams, - uri: path, - json: true, - } - - this.authentications.default.applyToRequest(requestOptions); - - if (Object.keys(formParams).length) { - if (useFormData) { - (requestOptions).formData = formParams; - } else { - requestOptions.form = formParams; - } - } - - request(requestOptions, (error, response, body) => { - if (error) { - deferred.reject(error); - } else { - if (response.statusCode >= 200 && response.statusCode <= 299) { - deferred.resolve({ response: response, body: body }); - } else { - deferred.reject({ response: response, body: body }); - } - } - }); - - return deferred.promise; - } - - public deleteOrder (orderId: string) : Promise<{ response: http.ClientResponse; }> { - var path = this.url + this.basePath + '/store/order/{orderId}'; - - path = path.replace('{' + 'orderId' + '}', String(orderId)); - - var queryParameters: any = {}; - var headerParams: any = {}; - var formParams: any = {}; - - // verify required parameter 'orderId' is set - if (!orderId) { - throw new Error('Missing required parameter orderId when calling deleteOrder'); - } - - var useFormData = false; - - var deferred = promise.defer<{ response: http.ClientResponse; }>(); - - var requestOptions: request.Options = { - method: 'DELETE', - qs: queryParameters, - headers: headerParams, - uri: path, - json: true, - } - - this.authentications.default.applyToRequest(requestOptions); - - if (Object.keys(formParams).length) { - if (useFormData) { - (requestOptions).formData = formParams; - } else { - requestOptions.form = formParams; - } - } - - request(requestOptions, (error, response, body) => { - if (error) { - deferred.reject(error); - } else { - if (response.statusCode >= 200 && response.statusCode <= 299) { - deferred.resolve({ response: response, body: body }); - } else { - deferred.reject({ response: response, body: body }); - } - } - }); - - return deferred.promise; - } -} export class PetApi { private basePath = 'http://petstore.swagger.io/v2'; public authentications = { @@ -777,6 +567,7 @@ export class PetApi { var headerParams: any = {}; var formParams: any = {}; + var useFormData = false; var deferred = promise.defer<{ response: http.ClientResponse; }>(); @@ -824,6 +615,7 @@ export class PetApi { var headerParams: any = {}; var formParams: any = {}; + var useFormData = false; var deferred = promise.defer<{ response: http.ClientResponse; }>(); @@ -871,6 +663,7 @@ export class PetApi { var headerParams: any = {}; var formParams: any = {}; + if (status !== undefined) { queryParameters['status'] = status; } @@ -921,6 +714,7 @@ export class PetApi { var headerParams: any = {}; var formParams: any = {}; + if (tags !== undefined) { queryParameters['tags'] = tags; } @@ -973,6 +767,7 @@ export class PetApi { var headerParams: any = {}; var formParams: any = {}; + // verify required parameter 'petId' is set if (!petId) { throw new Error('Missing required parameter petId when calling getPetById'); @@ -990,10 +785,10 @@ export class PetApi { json: true, } - this.authentications.petstore_auth.applyToRequest(requestOptions); - this.authentications.api_key.applyToRequest(requestOptions); + this.authentications.petstore_auth.applyToRequest(requestOptions); + this.authentications.default.applyToRequest(requestOptions); if (Object.keys(formParams).length) { @@ -1028,6 +823,7 @@ export class PetApi { var headerParams: any = {}; var formParams: any = {}; + // verify required parameter 'petId' is set if (!petId) { throw new Error('Missing required parameter petId when calling updatePetWithForm'); @@ -1089,12 +885,13 @@ export class PetApi { var headerParams: any = {}; var formParams: any = {}; + // verify required parameter 'petId' is set if (!petId) { throw new Error('Missing required parameter petId when calling deletePet'); } - headerParams['apiKey'] = apiKey; + headerParams['api_key'] = apiKey; var useFormData = false; @@ -1144,6 +941,7 @@ export class PetApi { var headerParams: any = {}; var formParams: any = {}; + // verify required parameter 'petId' is set if (!petId) { throw new Error('Missing required parameter petId when calling uploadFile'); @@ -1197,3 +995,225 @@ export class PetApi { return deferred.promise; } } +export class StoreApi { + private basePath = 'http://petstore.swagger.io/v2'; + public authentications = { + 'default': new VoidAuth(), + 'api_key': new ApiKeyAuth('header', 'api_key'), + 'petstore_auth': new OAuth(), + } + + constructor(url: string, basePath?: string); + constructor(private url: string, basePathOrUsername: string, password?: string, basePath?: string) { + if (password) { + if (basePath) { + this.basePath = basePath; + } + } else { + if (basePathOrUsername) { + this.basePath = basePathOrUsername + } + } + } + + set apiKey(key: string) { + this.authentications.api_key.apiKey = key; + } + + public getInventory () : Promise<{ response: http.ClientResponse; body: { [key: string]: number; }; }> { + var path = this.url + this.basePath + '/store/inventory'; + + var queryParameters: any = {}; + var headerParams: any = {}; + var formParams: any = {}; + + + var useFormData = false; + + var deferred = promise.defer<{ response: http.ClientResponse; body: { [key: string]: number; }; }>(); + + var requestOptions: request.Options = { + method: 'GET', + qs: queryParameters, + headers: headerParams, + uri: path, + json: true, + } + + this.authentications.api_key.applyToRequest(requestOptions); + + this.authentications.default.applyToRequest(requestOptions); + + if (Object.keys(formParams).length) { + if (useFormData) { + (requestOptions).formData = formParams; + } else { + requestOptions.form = formParams; + } + } + + request(requestOptions, (error, response, body) => { + if (error) { + deferred.reject(error); + } else { + if (response.statusCode >= 200 && response.statusCode <= 299) { + deferred.resolve({ response: response, body: body }); + } else { + deferred.reject({ response: response, body: body }); + } + } + }); + + return deferred.promise; + } + + public placeOrder (body?: Order) : Promise<{ response: http.ClientResponse; body: Order; }> { + var path = this.url + this.basePath + '/store/order'; + + var queryParameters: any = {}; + var headerParams: any = {}; + var formParams: any = {}; + + + var useFormData = false; + + var deferred = promise.defer<{ response: http.ClientResponse; body: Order; }>(); + + var requestOptions: request.Options = { + method: 'POST', + qs: queryParameters, + headers: headerParams, + uri: path, + json: true, + body: body, + } + + this.authentications.default.applyToRequest(requestOptions); + + if (Object.keys(formParams).length) { + if (useFormData) { + (requestOptions).formData = formParams; + } else { + requestOptions.form = formParams; + } + } + + request(requestOptions, (error, response, body) => { + if (error) { + deferred.reject(error); + } else { + if (response.statusCode >= 200 && response.statusCode <= 299) { + deferred.resolve({ response: response, body: body }); + } else { + deferred.reject({ response: response, body: body }); + } + } + }); + + return deferred.promise; + } + + public getOrderById (orderId: string) : Promise<{ response: http.ClientResponse; body: Order; }> { + var path = this.url + this.basePath + '/store/order/{orderId}'; + + path = path.replace('{' + 'orderId' + '}', String(orderId)); + + var queryParameters: any = {}; + var headerParams: any = {}; + var formParams: any = {}; + + + // verify required parameter 'orderId' is set + if (!orderId) { + throw new Error('Missing required parameter orderId when calling getOrderById'); + } + + var useFormData = false; + + var deferred = promise.defer<{ response: http.ClientResponse; body: Order; }>(); + + var requestOptions: request.Options = { + method: 'GET', + qs: queryParameters, + headers: headerParams, + uri: path, + json: true, + } + + this.authentications.default.applyToRequest(requestOptions); + + if (Object.keys(formParams).length) { + if (useFormData) { + (requestOptions).formData = formParams; + } else { + requestOptions.form = formParams; + } + } + + request(requestOptions, (error, response, body) => { + if (error) { + deferred.reject(error); + } else { + if (response.statusCode >= 200 && response.statusCode <= 299) { + deferred.resolve({ response: response, body: body }); + } else { + deferred.reject({ response: response, body: body }); + } + } + }); + + return deferred.promise; + } + + public deleteOrder (orderId: string) : Promise<{ response: http.ClientResponse; }> { + var path = this.url + this.basePath + '/store/order/{orderId}'; + + path = path.replace('{' + 'orderId' + '}', String(orderId)); + + var queryParameters: any = {}; + var headerParams: any = {}; + var formParams: any = {}; + + + // verify required parameter 'orderId' is set + if (!orderId) { + throw new Error('Missing required parameter orderId when calling deleteOrder'); + } + + var useFormData = false; + + var deferred = promise.defer<{ response: http.ClientResponse; }>(); + + var requestOptions: request.Options = { + method: 'DELETE', + qs: queryParameters, + headers: headerParams, + uri: path, + json: true, + } + + this.authentications.default.applyToRequest(requestOptions); + + if (Object.keys(formParams).length) { + if (useFormData) { + (requestOptions).formData = formParams; + } else { + requestOptions.form = formParams; + } + } + + request(requestOptions, (error, response, body) => { + if (error) { + deferred.reject(error); + } else { + if (response.statusCode >= 200 && response.statusCode <= 299) { + deferred.resolve({ response: response, body: body }); + } else { + deferred.reject({ response: response, body: body }); + } + } + }); + + return deferred.promise; + } +}