From 4edeed6053187d6c41d121821ce44f3e8e08db86 Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Wed, 2 Dec 2015 10:05:37 -0700 Subject: [PATCH 01/17] Clojure client: put docstrings in the right place in core.clj. --- .../src/main/resources/clojure/core.mustache | 6 ++++-- .../client/petstore/clojure/src/swagger_petstore/core.clj | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/clojure/core.mustache b/modules/swagger-codegen/src/main/resources/clojure/core.mustache index b05df804a7f..1a5de110ef3 100644 --- a/modules/swagger-codegen/src/main/resources/clojure/core.mustache +++ b/modules/swagger-codegen/src/main/resources/clojure/core.mustache @@ -169,15 +169,17 @@ (map (fn [[k v]] [k (normalize-param v)])) (into {}))) -(defn json-mime? [mime] +(defn json-mime? "Check if the given MIME is a standard JSON MIME or :json." + [mime] (if mime (or (= :json mime) (re-matches #"application/json(;.*)?" (name mime))))) -(defn json-preferred-mime [mimes] +(defn json-preferred-mime "Choose a MIME from the given MIMEs with JSON preferred, i.e. return JSON if included, otherwise return the first one." + [mimes] (-> (filter json-mime? mimes) first (or (first mimes)))) diff --git a/samples/client/petstore/clojure/src/swagger_petstore/core.clj b/samples/client/petstore/clojure/src/swagger_petstore/core.clj index bcb9ed99ad2..0054d0ff82d 100644 --- a/samples/client/petstore/clojure/src/swagger_petstore/core.clj +++ b/samples/client/petstore/clojure/src/swagger_petstore/core.clj @@ -169,15 +169,17 @@ (map (fn [[k v]] [k (normalize-param v)])) (into {}))) -(defn json-mime? [mime] +(defn json-mime? "Check if the given MIME is a standard JSON MIME or :json." + [mime] (if mime (or (= :json mime) (re-matches #"application/json(;.*)?" (name mime))))) -(defn json-preferred-mime [mimes] +(defn json-preferred-mime "Choose a MIME from the given MIMEs with JSON preferred, i.e. return JSON if included, otherwise return the first one." + [mimes] (-> (filter json-mime? mimes) first (or (first mimes)))) From bb341832a578eb8a711adb764198325314a6d7af Mon Sep 17 00:00:00 2001 From: wing328 Date: Sun, 6 Dec 2015 19:00:52 +0800 Subject: [PATCH 02/17] add http info to php api methods --- .../src/main/resources/php/ApiClient.mustache | 4 +- .../src/main/resources/php/api.mustache | 30 ++- .../php/SwaggerClient-php/lib/Api/PetApi.php | 183 +++++++++++++++--- .../SwaggerClient-php/lib/Api/StoreApi.php | 97 ++++++++-- .../php/SwaggerClient-php/lib/Api/UserApi.php | 173 ++++++++++++++--- .../php/SwaggerClient-php/lib/ApiClient.php | 4 +- 6 files changed, 416 insertions(+), 75 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache index 11fe3827d48..35c065c81de 100644 --- a/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache @@ -231,7 +231,7 @@ class ApiClient } else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) { // return raw body if response is a file if ($responseType == '\SplFileObject') { - return array($http_body, $http_header); + return array($http_body, $response_info['http_code'], $http_header); } $data = json_decode($http_body); @@ -249,7 +249,7 @@ class ApiClient $response_info['http_code'], $http_header, $data ); } - return array($data, $http_header); + return array($data, $response_info['http_code'], $http_header); } /** diff --git a/modules/swagger-codegen/src/main/resources/php/api.mustache b/modules/swagger-codegen/src/main/resources/php/api.mustache index 53a81030813..2ba06331d50 100644 --- a/modules/swagger-codegen/src/main/resources/php/api.mustache +++ b/modules/swagger-codegen/src/main/resources/php/api.mustache @@ -92,7 +92,7 @@ use \{{invokerPackage}}\ObjectSerializer; {{#operation}} /** - * {{{nickname}}} + * {{{operationId}}} * * {{{summary}}} * @@ -100,12 +100,28 @@ use \{{invokerPackage}}\ObjectSerializer; {{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} * @throws \{{invokerPackage}}\ApiException on non-2xx response */ - public function {{nickname}}({{#allParams}}${{paramName}}{{^required}}=null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) + public function {{operationId}} ({{#allParams}}${{paramName}}{{^required}}=null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) + { + list($response, $statusCode, $httpHeader) = $this->{{operationId}}WithHttpInfo ({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + return $response; + } + + + /** + * {{{operationId}}} + * + * {{{summary}}} + * + {{#allParams}} * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional){{/required}} + {{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} + * @throws \{{invokerPackage}}\ApiException on non-2xx response + */ + public function {{operationId}}WithHttpInfo ({{#allParams}}${{paramName}}{{^required}}=null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { {{#allParams}}{{#required}} // verify the required parameter '{{paramName}}' is set if (${{paramName}} === null) { - throw new \InvalidArgumentException('Missing the required parameter ${{paramName}} when calling {{nickname}}'); + throw new \InvalidArgumentException('Missing the required parameter ${{paramName}} when calling {{operationId}}'); }{{/required}}{{/allParams}} // parse inputs @@ -182,17 +198,17 @@ use \{{invokerPackage}}\ObjectSerializer; // make the API Call try { - list($response, $httpHeader) = $this->apiClient->callApi( + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, $headerParams{{#returnType}}, '{{returnType}}'{{/returnType}} ); {{#returnType}} if (!$response) { - return null; + return array(null, $statusCode, $httpHeader); } - return $this->apiClient->getSerializer()->deserialize($response, '{{returnType}}', $httpHeader); + return array($this->apiClient->getSerializer()->deserialize($response, '{{returnType}}', $httpHeader)); {{/returnType}} } catch (ApiException $e) { switch ($e->getCode()) { {{#responses}}{{#dataType}} @@ -205,7 +221,7 @@ use \{{invokerPackage}}\ObjectSerializer; throw $e; } {{#returnType}} - return null; + return array(null, $statusCode, $httpHeader); {{/returnType}} } {{/operation}} 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 bc03a7974d3..0e971841f50 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -100,7 +100,23 @@ class PetApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function updatePet($body=null) + public function updatePet ($body=null) + { + list($response, $statusCode, $httpHeader) = $this->updatePetWithHttpInfo ($body); + return $response; + } + + + /** + * updatePet + * + * Update an existing pet + * + * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (optional) + * @return void + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function updatePetWithHttpInfo ($body=null) { @@ -143,7 +159,7 @@ class PetApi // make the API Call try { - list($response, $httpHeader) = $this->apiClient->callApi( + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, $headerParams @@ -167,7 +183,23 @@ class PetApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function addPet($body=null) + public function addPet ($body=null) + { + list($response, $statusCode, $httpHeader) = $this->addPetWithHttpInfo ($body); + return $response; + } + + + /** + * addPet + * + * Add a new pet to the store + * + * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (optional) + * @return void + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function addPetWithHttpInfo ($body=null) { @@ -210,7 +242,7 @@ class PetApi // make the API Call try { - list($response, $httpHeader) = $this->apiClient->callApi( + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, $headerParams @@ -234,7 +266,23 @@ class PetApi * @return \Swagger\Client\Model\Pet[] * @throws \Swagger\Client\ApiException on non-2xx response */ - public function findPetsByStatus($status=null) + public function findPetsByStatus ($status=null) + { + list($response, $statusCode, $httpHeader) = $this->findPetsByStatusWithHttpInfo ($status); + return $response; + } + + + /** + * findPetsByStatus + * + * Finds Pets by status + * + * @param string[] $status Status values that need to be considered for filter (optional) + * @return \Swagger\Client\Model\Pet[] + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function findPetsByStatusWithHttpInfo ($status=null) { @@ -276,17 +324,17 @@ class PetApi // make the API Call try { - list($response, $httpHeader) = $this->apiClient->callApi( + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, $headerParams, '\Swagger\Client\Model\Pet[]' ); if (!$response) { - return null; + return array(null, $statusCode, $httpHeader); } - return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader); + return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader)); } catch (ApiException $e) { switch ($e->getCode()) { @@ -299,7 +347,7 @@ class PetApi throw $e; } - return null; + return array(null, $statusCode, $httpHeader); } @@ -312,7 +360,23 @@ class PetApi * @return \Swagger\Client\Model\Pet[] * @throws \Swagger\Client\ApiException on non-2xx response */ - public function findPetsByTags($tags=null) + public function findPetsByTags ($tags=null) + { + list($response, $statusCode, $httpHeader) = $this->findPetsByTagsWithHttpInfo ($tags); + return $response; + } + + + /** + * findPetsByTags + * + * Finds Pets by tags + * + * @param string[] $tags Tags to filter by (optional) + * @return \Swagger\Client\Model\Pet[] + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function findPetsByTagsWithHttpInfo ($tags=null) { @@ -354,17 +418,17 @@ class PetApi // make the API Call try { - list($response, $httpHeader) = $this->apiClient->callApi( + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, $headerParams, '\Swagger\Client\Model\Pet[]' ); if (!$response) { - return null; + return array(null, $statusCode, $httpHeader); } - return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader); + return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader)); } catch (ApiException $e) { switch ($e->getCode()) { @@ -377,7 +441,7 @@ class PetApi throw $e; } - return null; + return array(null, $statusCode, $httpHeader); } @@ -390,7 +454,23 @@ class PetApi * @return \Swagger\Client\Model\Pet * @throws \Swagger\Client\ApiException on non-2xx response */ - public function getPetById($pet_id) + public function getPetById ($pet_id) + { + list($response, $statusCode, $httpHeader) = $this->getPetByIdWithHttpInfo ($pet_id); + return $response; + } + + + /** + * getPetById + * + * Find pet by ID + * + * @param int $pet_id ID of pet that needs to be fetched (required) + * @return \Swagger\Client\Model\Pet + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function getPetByIdWithHttpInfo ($pet_id) { // verify the required parameter 'pet_id' is set @@ -442,17 +522,17 @@ class PetApi // make the API Call try { - list($response, $httpHeader) = $this->apiClient->callApi( + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, $headerParams, '\Swagger\Client\Model\Pet' ); if (!$response) { - return null; + return array(null, $statusCode, $httpHeader); } - return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet', $httpHeader); + return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet', $httpHeader)); } catch (ApiException $e) { switch ($e->getCode()) { @@ -465,7 +545,7 @@ class PetApi throw $e; } - return null; + return array(null, $statusCode, $httpHeader); } @@ -480,7 +560,25 @@ class PetApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function updatePetWithForm($pet_id, $name=null, $status=null) + public function updatePetWithForm ($pet_id, $name=null, $status=null) + { + list($response, $statusCode, $httpHeader) = $this->updatePetWithFormWithHttpInfo ($pet_id, $name, $status); + return $response; + } + + + /** + * updatePetWithForm + * + * Updates a pet in the store with form data + * + * @param string $pet_id ID of pet that needs to be updated (required) + * @param string $name Updated name of the pet (optional) + * @param string $status Updated status of the pet (optional) + * @return void + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function updatePetWithFormWithHttpInfo ($pet_id, $name=null, $status=null) { // verify the required parameter 'pet_id' is set @@ -542,7 +640,7 @@ class PetApi // make the API Call try { - list($response, $httpHeader) = $this->apiClient->callApi( + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, $headerParams @@ -567,7 +665,24 @@ class PetApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function deletePet($pet_id, $api_key=null) + public function deletePet ($pet_id, $api_key=null) + { + list($response, $statusCode, $httpHeader) = $this->deletePetWithHttpInfo ($pet_id, $api_key); + return $response; + } + + + /** + * deletePet + * + * Deletes a pet + * + * @param int $pet_id Pet id to delete (required) + * @param string $api_key (optional) + * @return void + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function deletePetWithHttpInfo ($pet_id, $api_key=null) { // verify the required parameter 'pet_id' is set @@ -620,7 +735,7 @@ class PetApi // make the API Call try { - list($response, $httpHeader) = $this->apiClient->callApi( + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, $headerParams @@ -646,7 +761,25 @@ class PetApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function uploadFile($pet_id, $additional_metadata=null, $file=null) + public function uploadFile ($pet_id, $additional_metadata=null, $file=null) + { + list($response, $statusCode, $httpHeader) = $this->uploadFileWithHttpInfo ($pet_id, $additional_metadata, $file); + return $response; + } + + + /** + * uploadFile + * + * uploads an image + * + * @param int $pet_id ID of pet to update (required) + * @param string $additional_metadata Additional data to pass to server (optional) + * @param \SplFileObject $file file to upload (optional) + * @return void + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function uploadFileWithHttpInfo ($pet_id, $additional_metadata=null, $file=null) { // verify the required parameter 'pet_id' is set @@ -714,7 +847,7 @@ class PetApi // make the API Call try { - list($response, $httpHeader) = $this->apiClient->callApi( + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, $headerParams diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php index d709330b056..d32b2ac783e 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php @@ -99,7 +99,22 @@ class StoreApi * @return map[string,int] * @throws \Swagger\Client\ApiException on non-2xx response */ - public function getInventory() + public function getInventory () + { + list($response, $statusCode, $httpHeader) = $this->getInventoryWithHttpInfo (); + return $response; + } + + + /** + * getInventory + * + * Returns pet inventories by status + * + * @return map[string,int] + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function getInventoryWithHttpInfo () { @@ -140,17 +155,17 @@ class StoreApi // make the API Call try { - list($response, $httpHeader) = $this->apiClient->callApi( + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, $headerParams, 'map[string,int]' ); if (!$response) { - return null; + return array(null, $statusCode, $httpHeader); } - return $this->apiClient->getSerializer()->deserialize($response, 'map[string,int]', $httpHeader); + return array($this->apiClient->getSerializer()->deserialize($response, 'map[string,int]', $httpHeader)); } catch (ApiException $e) { switch ($e->getCode()) { @@ -163,7 +178,7 @@ class StoreApi throw $e; } - return null; + return array(null, $statusCode, $httpHeader); } @@ -176,7 +191,23 @@ class StoreApi * @return \Swagger\Client\Model\Order * @throws \Swagger\Client\ApiException on non-2xx response */ - public function placeOrder($body=null) + public function placeOrder ($body=null) + { + list($response, $statusCode, $httpHeader) = $this->placeOrderWithHttpInfo ($body); + return $response; + } + + + /** + * placeOrder + * + * Place an order for a pet + * + * @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (optional) + * @return \Swagger\Client\Model\Order + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function placeOrderWithHttpInfo ($body=null) { @@ -214,17 +245,17 @@ class StoreApi // make the API Call try { - list($response, $httpHeader) = $this->apiClient->callApi( + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, $headerParams, '\Swagger\Client\Model\Order' ); if (!$response) { - return null; + return array(null, $statusCode, $httpHeader); } - return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader); + return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader)); } catch (ApiException $e) { switch ($e->getCode()) { @@ -237,7 +268,7 @@ class StoreApi throw $e; } - return null; + return array(null, $statusCode, $httpHeader); } @@ -250,7 +281,23 @@ class StoreApi * @return \Swagger\Client\Model\Order * @throws \Swagger\Client\ApiException on non-2xx response */ - public function getOrderById($order_id) + public function getOrderById ($order_id) + { + list($response, $statusCode, $httpHeader) = $this->getOrderByIdWithHttpInfo ($order_id); + return $response; + } + + + /** + * getOrderById + * + * Find purchase order by ID + * + * @param string $order_id ID of pet that needs to be fetched (required) + * @return \Swagger\Client\Model\Order + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function getOrderByIdWithHttpInfo ($order_id) { // verify the required parameter 'order_id' is set @@ -295,17 +342,17 @@ class StoreApi // make the API Call try { - list($response, $httpHeader) = $this->apiClient->callApi( + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, $headerParams, '\Swagger\Client\Model\Order' ); if (!$response) { - return null; + return array(null, $statusCode, $httpHeader); } - return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader); + return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader)); } catch (ApiException $e) { switch ($e->getCode()) { @@ -318,7 +365,7 @@ class StoreApi throw $e; } - return null; + return array(null, $statusCode, $httpHeader); } @@ -331,7 +378,23 @@ class StoreApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function deleteOrder($order_id) + public function deleteOrder ($order_id) + { + list($response, $statusCode, $httpHeader) = $this->deleteOrderWithHttpInfo ($order_id); + return $response; + } + + + /** + * deleteOrder + * + * Delete purchase order by ID + * + * @param string $order_id ID of the order that needs to be deleted (required) + * @return void + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function deleteOrderWithHttpInfo ($order_id) { // verify the required parameter 'order_id' is set @@ -376,7 +439,7 @@ class StoreApi // make the API Call try { - list($response, $httpHeader) = $this->apiClient->callApi( + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, $headerParams diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php index 8ce6301a51e..890b876a106 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php @@ -100,7 +100,23 @@ class UserApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function createUser($body=null) + public function createUser ($body=null) + { + list($response, $statusCode, $httpHeader) = $this->createUserWithHttpInfo ($body); + return $response; + } + + + /** + * createUser + * + * Create user + * + * @param \Swagger\Client\Model\User $body Created user object (optional) + * @return void + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function createUserWithHttpInfo ($body=null) { @@ -138,7 +154,7 @@ class UserApi // make the API Call try { - list($response, $httpHeader) = $this->apiClient->callApi( + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, $headerParams @@ -162,7 +178,23 @@ class UserApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function createUsersWithArrayInput($body=null) + public function createUsersWithArrayInput ($body=null) + { + list($response, $statusCode, $httpHeader) = $this->createUsersWithArrayInputWithHttpInfo ($body); + return $response; + } + + + /** + * createUsersWithArrayInput + * + * Creates list of users with given input array + * + * @param \Swagger\Client\Model\User[] $body List of user object (optional) + * @return void + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function createUsersWithArrayInputWithHttpInfo ($body=null) { @@ -200,7 +232,7 @@ class UserApi // make the API Call try { - list($response, $httpHeader) = $this->apiClient->callApi( + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, $headerParams @@ -224,7 +256,23 @@ class UserApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function createUsersWithListInput($body=null) + public function createUsersWithListInput ($body=null) + { + list($response, $statusCode, $httpHeader) = $this->createUsersWithListInputWithHttpInfo ($body); + return $response; + } + + + /** + * createUsersWithListInput + * + * Creates list of users with given input array + * + * @param \Swagger\Client\Model\User[] $body List of user object (optional) + * @return void + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function createUsersWithListInputWithHttpInfo ($body=null) { @@ -262,7 +310,7 @@ class UserApi // make the API Call try { - list($response, $httpHeader) = $this->apiClient->callApi( + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, $headerParams @@ -287,7 +335,24 @@ class UserApi * @return string * @throws \Swagger\Client\ApiException on non-2xx response */ - public function loginUser($username=null, $password=null) + public function loginUser ($username=null, $password=null) + { + list($response, $statusCode, $httpHeader) = $this->loginUserWithHttpInfo ($username, $password); + return $response; + } + + + /** + * loginUser + * + * Logs user into the system + * + * @param string $username The user name for login (optional) + * @param string $password The password for login in clear text (optional) + * @return string + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function loginUserWithHttpInfo ($username=null, $password=null) { @@ -327,17 +392,17 @@ class UserApi // make the API Call try { - list($response, $httpHeader) = $this->apiClient->callApi( + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, $headerParams, 'string' ); if (!$response) { - return null; + return array(null, $statusCode, $httpHeader); } - return $this->apiClient->getSerializer()->deserialize($response, 'string', $httpHeader); + return array($this->apiClient->getSerializer()->deserialize($response, 'string', $httpHeader)); } catch (ApiException $e) { switch ($e->getCode()) { @@ -350,7 +415,7 @@ class UserApi throw $e; } - return null; + return array(null, $statusCode, $httpHeader); } @@ -362,7 +427,22 @@ class UserApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function logoutUser() + public function logoutUser () + { + list($response, $statusCode, $httpHeader) = $this->logoutUserWithHttpInfo (); + return $response; + } + + + /** + * logoutUser + * + * Logs out current logged in user session + * + * @return void + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function logoutUserWithHttpInfo () { @@ -396,7 +476,7 @@ class UserApi // make the API Call try { - list($response, $httpHeader) = $this->apiClient->callApi( + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, $headerParams @@ -420,7 +500,23 @@ class UserApi * @return \Swagger\Client\Model\User * @throws \Swagger\Client\ApiException on non-2xx response */ - public function getUserByName($username) + public function getUserByName ($username) + { + list($response, $statusCode, $httpHeader) = $this->getUserByNameWithHttpInfo ($username); + return $response; + } + + + /** + * getUserByName + * + * Get user by user name + * + * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * @return \Swagger\Client\Model\User + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function getUserByNameWithHttpInfo ($username) { // verify the required parameter 'username' is set @@ -465,17 +561,17 @@ class UserApi // make the API Call try { - list($response, $httpHeader) = $this->apiClient->callApi( + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, $headerParams, '\Swagger\Client\Model\User' ); if (!$response) { - return null; + return array(null, $statusCode, $httpHeader); } - return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\User', $httpHeader); + return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\User', $httpHeader)); } catch (ApiException $e) { switch ($e->getCode()) { @@ -488,7 +584,7 @@ class UserApi throw $e; } - return null; + return array(null, $statusCode, $httpHeader); } @@ -502,7 +598,24 @@ class UserApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function updateUser($username, $body=null) + public function updateUser ($username, $body=null) + { + list($response, $statusCode, $httpHeader) = $this->updateUserWithHttpInfo ($username, $body); + return $response; + } + + + /** + * updateUser + * + * Updated user + * + * @param string $username name that need to be deleted (required) + * @param \Swagger\Client\Model\User $body Updated user object (optional) + * @return void + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function updateUserWithHttpInfo ($username, $body=null) { // verify the required parameter 'username' is set @@ -551,7 +664,7 @@ class UserApi // make the API Call try { - list($response, $httpHeader) = $this->apiClient->callApi( + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, $headerParams @@ -575,7 +688,23 @@ class UserApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function deleteUser($username) + public function deleteUser ($username) + { + list($response, $statusCode, $httpHeader) = $this->deleteUserWithHttpInfo ($username); + return $response; + } + + + /** + * deleteUser + * + * Delete user + * + * @param string $username The name that needs to be deleted (required) + * @return void + * @throws \Swagger\Client\ApiException on non-2xx response + */ + public function deleteUserWithHttpInfo ($username) { // verify the required parameter 'username' is set @@ -620,7 +749,7 @@ class UserApi // make the API Call try { - list($response, $httpHeader) = $this->apiClient->callApi( + list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, $headerParams diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php b/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php index a0bb07273e4..b5b63793e85 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php @@ -231,7 +231,7 @@ class ApiClient } else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) { // return raw body if response is a file if ($responseType == '\SplFileObject') { - return array($http_body, $http_header); + return array($http_body, $response_info['http_code'], $http_header); } $data = json_decode($http_body); @@ -249,7 +249,7 @@ class ApiClient $response_info['http_code'], $http_header, $data ); } - return array($data, $http_header); + return array($data, $response_info['http_code'], $http_header); } /** From b282d4fbea9a1265aef7099104324ffb70e2b5b8 Mon Sep 17 00:00:00 2001 From: wing328 Date: Sun, 6 Dec 2015 23:58:25 +0800 Subject: [PATCH 03/17] add http_parse_headers, update test case --- .../src/main/resources/php/ApiClient.mustache | 50 ++++++++++++++++++- .../resources/php/ObjectSerializer.mustache | 2 +- .../src/main/resources/php/api.mustache | 7 ++- .../php/SwaggerClient-php/lib/Api/PetApi.php | 26 ++++------ .../SwaggerClient-php/lib/Api/StoreApi.php | 22 ++++---- .../php/SwaggerClient-php/lib/Api/UserApi.php | 20 +++----- .../php/SwaggerClient-php/lib/ApiClient.php | 50 ++++++++++++++++++- .../lib/ObjectSerializer.php | 2 +- .../SwaggerClient-php/tests/PetApiTest.php | 19 +++++++ 9 files changed, 146 insertions(+), 52 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache index 35c065c81de..86998fd16d0 100644 --- a/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache @@ -216,7 +216,7 @@ class ApiClient // Make the request $response = curl_exec($curl); $http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE); - $http_header = substr($response, 0, $http_header_size); + $http_header = $this->http_parse_headers(substr($response, 0, $http_header_size)); $http_body = substr($response, $http_header_size); $response_info = curl_getinfo($curl); @@ -287,4 +287,52 @@ class ApiClient return implode(',', $content_type); } } + + /** + * Return an array of HTTP response headers + * + * @param string $raw_headers A string of raw HTTP response headers + * + * @return string[] Array of HTTP response heaers + */ + protected function http_parse_headers($raw_headers) + { + // ref/credit: http://php.net/manual/en/function.http-parse-headers.php#112986 + $headers = array(); + $key = ''; // [+] + + foreach(explode("\n", $raw_headers) as $i => $h) + { + $h = explode(':', $h, 2); + + if (isset($h[1])) + { + if (!isset($headers[$h[0]])) + $headers[$h[0]] = trim($h[1]); + elseif (is_array($headers[$h[0]])) + { + // $tmp = array_merge($headers[$h[0]], array(trim($h[1]))); // [-] + // $headers[$h[0]] = $tmp; // [-] + $headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1]))); // [+] + } + else + { + // $tmp = array_merge(array($headers[$h[0]]), array(trim($h[1]))); // [-] + // $headers[$h[0]] = $tmp; // [-] + $headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1]))); // [+] + } + + $key = $h[0]; // [+] + } + else // [+] + { // [+] + if (substr($h[0], 0, 1) == "\t") // [+] + $headers[$key] .= "\r\n\t".trim($h[0]); // [+] + elseif (!$key) // [+] + $headers[0] = trim($h[0]);trim($h[0]); // [+] + } // [+] + } + + return $headers; + } } diff --git a/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache b/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache index 45b56aa9b97..54fb66a9543 100644 --- a/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache +++ b/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache @@ -198,7 +198,7 @@ class ObjectSerializer $deserialized = $data; } elseif ($class === '\SplFileObject') { // determine file name - if (preg_match('/Content-Disposition: inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeader, $match)) { + if (array_key_exists('Content-Disposition', $httpHeaders) && preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeader['Content-Disposition'], $match)) { $filename = Configuration::getDefaultConfiguration()->getTempFolderPath().$match[1]; } else { $filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), ''); diff --git a/modules/swagger-codegen/src/main/resources/php/api.mustache b/modules/swagger-codegen/src/main/resources/php/api.mustache index 2ba06331d50..7cd4e659b98 100644 --- a/modules/swagger-codegen/src/main/resources/php/api.mustache +++ b/modules/swagger-codegen/src/main/resources/php/api.mustache @@ -208,7 +208,9 @@ use \{{invokerPackage}}\ObjectSerializer; return array(null, $statusCode, $httpHeader); } - return array($this->apiClient->getSerializer()->deserialize($response, '{{returnType}}', $httpHeader)); + return array($this->apiClient->getSerializer()->deserialize($response, '{{returnType}}', $httpHeader), $statusCode, $httpHeader); + {{/returnType}}{{#returnType}} + return array(null, $statusCode, $httpHeader); {{/returnType}} } catch (ApiException $e) { switch ($e->getCode()) { {{#responses}}{{#dataType}} @@ -220,9 +222,6 @@ use \{{invokerPackage}}\ObjectSerializer; throw $e; } - {{#returnType}} - return array(null, $statusCode, $httpHeader); - {{/returnType}} } {{/operation}} } 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 0e971841f50..44b35efe7ae 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -171,7 +171,6 @@ class PetApi throw $e; } - } /** @@ -254,7 +253,6 @@ class PetApi throw $e; } - } /** @@ -334,7 +332,9 @@ class PetApi return array(null, $statusCode, $httpHeader); } - return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader)); + return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader), $statusCode, $httpHeader); + + return array(null, $statusCode, $httpHeader); } catch (ApiException $e) { switch ($e->getCode()) { @@ -346,9 +346,6 @@ class PetApi throw $e; } - - return array(null, $statusCode, $httpHeader); - } /** @@ -428,7 +425,9 @@ class PetApi return array(null, $statusCode, $httpHeader); } - return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader)); + return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader), $statusCode, $httpHeader); + + return array(null, $statusCode, $httpHeader); } catch (ApiException $e) { switch ($e->getCode()) { @@ -440,9 +439,6 @@ class PetApi throw $e; } - - return array(null, $statusCode, $httpHeader); - } /** @@ -532,7 +528,9 @@ class PetApi return array(null, $statusCode, $httpHeader); } - return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet', $httpHeader)); + return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet', $httpHeader), $statusCode, $httpHeader); + + return array(null, $statusCode, $httpHeader); } catch (ApiException $e) { switch ($e->getCode()) { @@ -544,9 +542,6 @@ class PetApi throw $e; } - - return array(null, $statusCode, $httpHeader); - } /** @@ -652,7 +647,6 @@ class PetApi throw $e; } - } /** @@ -747,7 +741,6 @@ class PetApi throw $e; } - } /** @@ -859,7 +852,6 @@ class PetApi throw $e; } - } } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php index d32b2ac783e..26b25027a1b 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php @@ -165,7 +165,9 @@ class StoreApi return array(null, $statusCode, $httpHeader); } - return array($this->apiClient->getSerializer()->deserialize($response, 'map[string,int]', $httpHeader)); + return array($this->apiClient->getSerializer()->deserialize($response, 'map[string,int]', $httpHeader), $statusCode, $httpHeader); + + return array(null, $statusCode, $httpHeader); } catch (ApiException $e) { switch ($e->getCode()) { @@ -177,9 +179,6 @@ class StoreApi throw $e; } - - return array(null, $statusCode, $httpHeader); - } /** @@ -255,7 +254,9 @@ class StoreApi return array(null, $statusCode, $httpHeader); } - return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader)); + return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader), $statusCode, $httpHeader); + + return array(null, $statusCode, $httpHeader); } catch (ApiException $e) { switch ($e->getCode()) { @@ -267,9 +268,6 @@ class StoreApi throw $e; } - - return array(null, $statusCode, $httpHeader); - } /** @@ -352,7 +350,9 @@ class StoreApi return array(null, $statusCode, $httpHeader); } - return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader)); + return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader), $statusCode, $httpHeader); + + return array(null, $statusCode, $httpHeader); } catch (ApiException $e) { switch ($e->getCode()) { @@ -364,9 +364,6 @@ class StoreApi throw $e; } - - return array(null, $statusCode, $httpHeader); - } /** @@ -451,7 +448,6 @@ class StoreApi throw $e; } - } } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php index 890b876a106..9e2f3aa9eab 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php @@ -166,7 +166,6 @@ class UserApi throw $e; } - } /** @@ -244,7 +243,6 @@ class UserApi throw $e; } - } /** @@ -322,7 +320,6 @@ class UserApi throw $e; } - } /** @@ -402,7 +399,9 @@ class UserApi return array(null, $statusCode, $httpHeader); } - return array($this->apiClient->getSerializer()->deserialize($response, 'string', $httpHeader)); + return array($this->apiClient->getSerializer()->deserialize($response, 'string', $httpHeader), $statusCode, $httpHeader); + + return array(null, $statusCode, $httpHeader); } catch (ApiException $e) { switch ($e->getCode()) { @@ -414,9 +413,6 @@ class UserApi throw $e; } - - return array(null, $statusCode, $httpHeader); - } /** @@ -488,7 +484,6 @@ class UserApi throw $e; } - } /** @@ -571,7 +566,9 @@ class UserApi return array(null, $statusCode, $httpHeader); } - return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\User', $httpHeader)); + return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\User', $httpHeader), $statusCode, $httpHeader); + + return array(null, $statusCode, $httpHeader); } catch (ApiException $e) { switch ($e->getCode()) { @@ -583,9 +580,6 @@ class UserApi throw $e; } - - return array(null, $statusCode, $httpHeader); - } /** @@ -676,7 +670,6 @@ class UserApi throw $e; } - } /** @@ -761,7 +754,6 @@ class UserApi throw $e; } - } } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php b/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php index b5b63793e85..2f3aacd1ffd 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php @@ -216,7 +216,7 @@ class ApiClient // Make the request $response = curl_exec($curl); $http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE); - $http_header = substr($response, 0, $http_header_size); + $http_header = $this->http_parse_headers(substr($response, 0, $http_header_size)); $http_body = substr($response, $http_header_size); $response_info = curl_getinfo($curl); @@ -287,4 +287,52 @@ class ApiClient return implode(',', $content_type); } } + + /** + * Return an array of HTTP response headers + * + * @param string $raw_headers A string of raw HTTP response headers + * + * @return string[] Array of HTTP response heaers + */ + protected function http_parse_headers($raw_headers) + { + // ref/credit: http://php.net/manual/en/function.http-parse-headers.php#112986 + $headers = array(); + $key = ''; // [+] + + foreach(explode("\n", $raw_headers) as $i => $h) + { + $h = explode(':', $h, 2); + + if (isset($h[1])) + { + if (!isset($headers[$h[0]])) + $headers[$h[0]] = trim($h[1]); + elseif (is_array($headers[$h[0]])) + { + // $tmp = array_merge($headers[$h[0]], array(trim($h[1]))); // [-] + // $headers[$h[0]] = $tmp; // [-] + $headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1]))); // [+] + } + else + { + // $tmp = array_merge(array($headers[$h[0]]), array(trim($h[1]))); // [-] + // $headers[$h[0]] = $tmp; // [-] + $headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1]))); // [+] + } + + $key = $h[0]; // [+] + } + else // [+] + { // [+] + if (substr($h[0], 0, 1) == "\t") // [+] + $headers[$key] .= "\r\n\t".trim($h[0]); // [+] + elseif (!$key) // [+] + $headers[0] = trim($h[0]);trim($h[0]); // [+] + } // [+] + } + + return $headers; + } } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php index 0d281b9d1fa..22d03030fb3 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php @@ -198,7 +198,7 @@ class ObjectSerializer $deserialized = $data; } elseif ($class === '\SplFileObject') { // determine file name - if (preg_match('/Content-Disposition: inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeader, $match)) { + if (array_key_exists('Content-Disposition', $httpHeaders) && preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeader['Content-Disposition'], $match)) { $filename = Configuration::getDefaultConfiguration()->getTempFolderPath().$match[1]; } else { $filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), ''); diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php index 58d5cd661f4..c30c95eaa69 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php @@ -105,6 +105,25 @@ class PetApiTest extends \PHPUnit_Framework_TestCase $this->assertSame($response->getTags()[0]->getName(), 'test php tag'); } + // test getPetById with a Pet object (id 10005) + public function testGetPetByIdWithHttpInfo() + { + // initialize the API client without host + $pet_id = 10005; // ID of pet that needs to be fetched + $pet_api = new Swagger\Client\Api\PetAPI(); + $pet_api->getApiClient()->getConfig()->setApiKey('api_key', '111222333444555'); + // return Pet (model) + list($response, $status_code, $response_headers) = $pet_api->getPetByIdWithHttpInfo($pet_id); + $this->assertSame($response->getId(), $pet_id); + $this->assertSame($response->getName(), 'PHP Unit Test'); + $this->assertSame($response->getCategory()->getId(), $pet_id); + $this->assertSame($response->getCategory()->getName(), 'test php category'); + $this->assertSame($response->getTags()[0]->getId(), $pet_id); + $this->assertSame($response->getTags()[0]->getName(), 'test php tag'); + $this->assertSame($status_code, 200); + $this->assertSame($response_headers['Content-Type'], 'application/json'); + } + // test getPetByStatus and verify by the "id" of the response public function testFindPetByStatus() { From 11466570f752fe15e8e0d09d0f7cdd6a95e960f1 Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 7 Dec 2015 00:30:17 +0800 Subject: [PATCH 04/17] php add test case for withinfo method returnig void --- .../src/main/resources/php/api.mustache | 6 ++-- .../php/SwaggerClient-php/lib/Api/PetApi.php | 32 +++++++++++-------- .../SwaggerClient-php/lib/Api/StoreApi.php | 16 ++++------ .../php/SwaggerClient-php/lib/Api/UserApi.php | 32 ++++++++++++------- .../SwaggerClient-php/tests/PetApiTest.php | 21 +++++++++++- 5 files changed, 67 insertions(+), 40 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/php/api.mustache b/modules/swagger-codegen/src/main/resources/php/api.mustache index 7cd4e659b98..0b28b2b4ca6 100644 --- a/modules/swagger-codegen/src/main/resources/php/api.mustache +++ b/modules/swagger-codegen/src/main/resources/php/api.mustache @@ -108,12 +108,12 @@ use \{{invokerPackage}}\ObjectSerializer; /** - * {{{operationId}}} + * {{{operationId}}}WithHttpInfo * * {{{summary}}} * {{#allParams}} * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional){{/required}} - {{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} + {{/allParams}} * @return Array of {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}null{{/returnType}}, HTTP status code, HTTP response headers (array of strings) * @throws \{{invokerPackage}}\ApiException on non-2xx response */ public function {{operationId}}WithHttpInfo ({{#allParams}}${{paramName}}{{^required}}=null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) @@ -209,7 +209,7 @@ use \{{invokerPackage}}\ObjectSerializer; } return array($this->apiClient->getSerializer()->deserialize($response, '{{returnType}}', $httpHeader), $statusCode, $httpHeader); - {{/returnType}}{{#returnType}} + {{/returnType}}{{^returnType}} return array(null, $statusCode, $httpHeader); {{/returnType}} } catch (ApiException $e) { 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 44b35efe7ae..792053877a4 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -113,7 +113,7 @@ class PetApi * Update an existing pet * * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (optional) - * @return void + * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ public function updatePetWithHttpInfo ($body=null) @@ -165,6 +165,8 @@ class PetApi $headerParams ); + return array(null, $statusCode, $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { } @@ -195,7 +197,7 @@ class PetApi * Add a new pet to the store * * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (optional) - * @return void + * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ public function addPetWithHttpInfo ($body=null) @@ -247,6 +249,8 @@ class PetApi $headerParams ); + return array(null, $statusCode, $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { } @@ -277,7 +281,7 @@ class PetApi * Finds Pets by status * * @param string[] $status Status values that need to be considered for filter (optional) - * @return \Swagger\Client\Model\Pet[] + * @return Array of \Swagger\Client\Model\Pet[], HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ public function findPetsByStatusWithHttpInfo ($status=null) @@ -334,8 +338,6 @@ class PetApi return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader), $statusCode, $httpHeader); - return array(null, $statusCode, $httpHeader); - } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -370,7 +372,7 @@ class PetApi * Finds Pets by tags * * @param string[] $tags Tags to filter by (optional) - * @return \Swagger\Client\Model\Pet[] + * @return Array of \Swagger\Client\Model\Pet[], HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ public function findPetsByTagsWithHttpInfo ($tags=null) @@ -427,8 +429,6 @@ class PetApi return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader), $statusCode, $httpHeader); - return array(null, $statusCode, $httpHeader); - } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -463,7 +463,7 @@ class PetApi * Find pet by ID * * @param int $pet_id ID of pet that needs to be fetched (required) - * @return \Swagger\Client\Model\Pet + * @return Array of \Swagger\Client\Model\Pet, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ public function getPetByIdWithHttpInfo ($pet_id) @@ -530,8 +530,6 @@ class PetApi return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet', $httpHeader), $statusCode, $httpHeader); - return array(null, $statusCode, $httpHeader); - } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -570,7 +568,7 @@ class PetApi * @param string $pet_id ID of pet that needs to be updated (required) * @param string $name Updated name of the pet (optional) * @param string $status Updated status of the pet (optional) - * @return void + * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ public function updatePetWithFormWithHttpInfo ($pet_id, $name=null, $status=null) @@ -641,6 +639,8 @@ class PetApi $headerParams ); + return array(null, $statusCode, $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { } @@ -673,7 +673,7 @@ class PetApi * * @param int $pet_id Pet id to delete (required) * @param string $api_key (optional) - * @return void + * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ public function deletePetWithHttpInfo ($pet_id, $api_key=null) @@ -735,6 +735,8 @@ class PetApi $headerParams ); + return array(null, $statusCode, $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { } @@ -769,7 +771,7 @@ class PetApi * @param int $pet_id ID of pet to update (required) * @param string $additional_metadata Additional data to pass to server (optional) * @param \SplFileObject $file file to upload (optional) - * @return void + * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ public function uploadFileWithHttpInfo ($pet_id, $additional_metadata=null, $file=null) @@ -846,6 +848,8 @@ class PetApi $headerParams ); + return array(null, $statusCode, $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php index 26b25027a1b..3d8d14139c0 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php @@ -111,7 +111,7 @@ class StoreApi * * Returns pet inventories by status * - * @return map[string,int] + * @return Array of map[string,int], HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ public function getInventoryWithHttpInfo () @@ -167,8 +167,6 @@ class StoreApi return array($this->apiClient->getSerializer()->deserialize($response, 'map[string,int]', $httpHeader), $statusCode, $httpHeader); - return array(null, $statusCode, $httpHeader); - } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -203,7 +201,7 @@ class StoreApi * Place an order for a pet * * @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (optional) - * @return \Swagger\Client\Model\Order + * @return Array of \Swagger\Client\Model\Order, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ public function placeOrderWithHttpInfo ($body=null) @@ -256,8 +254,6 @@ class StoreApi return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader), $statusCode, $httpHeader); - return array(null, $statusCode, $httpHeader); - } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -292,7 +288,7 @@ class StoreApi * Find purchase order by ID * * @param string $order_id ID of pet that needs to be fetched (required) - * @return \Swagger\Client\Model\Order + * @return Array of \Swagger\Client\Model\Order, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ public function getOrderByIdWithHttpInfo ($order_id) @@ -352,8 +348,6 @@ class StoreApi return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader), $statusCode, $httpHeader); - return array(null, $statusCode, $httpHeader); - } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -388,7 +382,7 @@ class StoreApi * Delete purchase order by ID * * @param string $order_id ID of the order that needs to be deleted (required) - * @return void + * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ public function deleteOrderWithHttpInfo ($order_id) @@ -442,6 +436,8 @@ class StoreApi $headerParams ); + return array(null, $statusCode, $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php index 9e2f3aa9eab..588f2b0a2e1 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php @@ -113,7 +113,7 @@ class UserApi * Create user * * @param \Swagger\Client\Model\User $body Created user object (optional) - * @return void + * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ public function createUserWithHttpInfo ($body=null) @@ -160,6 +160,8 @@ class UserApi $headerParams ); + return array(null, $statusCode, $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { } @@ -190,7 +192,7 @@ class UserApi * Creates list of users with given input array * * @param \Swagger\Client\Model\User[] $body List of user object (optional) - * @return void + * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ public function createUsersWithArrayInputWithHttpInfo ($body=null) @@ -237,6 +239,8 @@ class UserApi $headerParams ); + return array(null, $statusCode, $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { } @@ -267,7 +271,7 @@ class UserApi * Creates list of users with given input array * * @param \Swagger\Client\Model\User[] $body List of user object (optional) - * @return void + * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ public function createUsersWithListInputWithHttpInfo ($body=null) @@ -314,6 +318,8 @@ class UserApi $headerParams ); + return array(null, $statusCode, $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { } @@ -346,7 +352,7 @@ class UserApi * * @param string $username The user name for login (optional) * @param string $password The password for login in clear text (optional) - * @return string + * @return Array of string, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ public function loginUserWithHttpInfo ($username=null, $password=null) @@ -401,8 +407,6 @@ class UserApi return array($this->apiClient->getSerializer()->deserialize($response, 'string', $httpHeader), $statusCode, $httpHeader); - return array(null, $statusCode, $httpHeader); - } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -435,7 +439,7 @@ class UserApi * * Logs out current logged in user session * - * @return void + * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ public function logoutUserWithHttpInfo () @@ -478,6 +482,8 @@ class UserApi $headerParams ); + return array(null, $statusCode, $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { } @@ -508,7 +514,7 @@ class UserApi * Get user by user name * * @param string $username The name that needs to be fetched. Use user1 for testing. (required) - * @return \Swagger\Client\Model\User + * @return Array of \Swagger\Client\Model\User, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ public function getUserByNameWithHttpInfo ($username) @@ -568,8 +574,6 @@ class UserApi return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\User', $httpHeader), $statusCode, $httpHeader); - return array(null, $statusCode, $httpHeader); - } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -606,7 +610,7 @@ class UserApi * * @param string $username name that need to be deleted (required) * @param \Swagger\Client\Model\User $body Updated user object (optional) - * @return void + * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ public function updateUserWithHttpInfo ($username, $body=null) @@ -664,6 +668,8 @@ class UserApi $headerParams ); + return array(null, $statusCode, $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { } @@ -694,7 +700,7 @@ class UserApi * Delete user * * @param string $username The name that needs to be deleted (required) - * @return void + * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ public function deleteUserWithHttpInfo ($username) @@ -748,6 +754,8 @@ class UserApi $headerParams ); + return array(null, $statusCode, $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { } diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php index c30c95eaa69..c81b07b38fd 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php @@ -168,7 +168,26 @@ class PetApiTest extends \PHPUnit_Framework_TestCase $this->assertSame($response->getName(), 'updatePet'); } - // test updatePet and verify by the "id" of the response + // test updatePetWithFormWithHttpInfo and verify by the "name" of the response + public function testUpdatePetWithFormWithHttpInfo() + { + // initialize the API client + $config = (new Swagger\Client\Configuration())->setHost('http://petstore.swagger.io/v2'); + $api_client = new Swagger\Client\ApiClient($config); + $pet_id = 10001; // ID of pet that needs to be fetched + $pet_api = new Swagger\Client\Api\PetAPI($api_client); + // update Pet (form) + list($update_response, $status_code, $http_headers) = $pet_api->updatePetWithFormWithHttpInfo($pet_id, 'update pet with form with http info'); + // return nothing (void) + $this->assertNull($update_response); + $this->assertSame($status_code, 200); + $this->assertSame($http_headers['Content-Type'], 'application/json'); + $response = $pet_api->getPetById($pet_id); + $this->assertSame($response->getId(), $pet_id); + $this->assertSame($response->getName(), 'update pet with form with http info'); + } + + // test updatePetWithForm and verify by the "name" and "status" of the response public function testUpdatePetWithForm() { // initialize the API client From 17b14fa281aa73677ef2dc632332f12b57fda651 Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 7 Dec 2015 00:37:22 +0800 Subject: [PATCH 05/17] update php sample --- .../php/SwaggerClient-php/lib/Api/PetApi.php | 16 ++++++++-------- .../php/SwaggerClient-php/lib/Api/StoreApi.php | 8 ++++---- .../php/SwaggerClient-php/lib/Api/UserApi.php | 16 ++++++++-------- 3 files changed, 20 insertions(+), 20 deletions(-) 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 792053877a4..c5ac2e17eb9 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -108,7 +108,7 @@ class PetApi /** - * updatePet + * updatePetWithHttpInfo * * Update an existing pet * @@ -192,7 +192,7 @@ class PetApi /** - * addPet + * addPetWithHttpInfo * * Add a new pet to the store * @@ -276,7 +276,7 @@ class PetApi /** - * findPetsByStatus + * findPetsByStatusWithHttpInfo * * Finds Pets by status * @@ -367,7 +367,7 @@ class PetApi /** - * findPetsByTags + * findPetsByTagsWithHttpInfo * * Finds Pets by tags * @@ -458,7 +458,7 @@ class PetApi /** - * getPetById + * getPetByIdWithHttpInfo * * Find pet by ID * @@ -561,7 +561,7 @@ class PetApi /** - * updatePetWithForm + * updatePetWithFormWithHttpInfo * * Updates a pet in the store with form data * @@ -667,7 +667,7 @@ class PetApi /** - * deletePet + * deletePetWithHttpInfo * * Deletes a pet * @@ -764,7 +764,7 @@ class PetApi /** - * uploadFile + * uploadFileWithHttpInfo * * uploads an image * diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php index 3d8d14139c0..3deab979d41 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php @@ -107,7 +107,7 @@ class StoreApi /** - * getInventory + * getInventoryWithHttpInfo * * Returns pet inventories by status * @@ -196,7 +196,7 @@ class StoreApi /** - * placeOrder + * placeOrderWithHttpInfo * * Place an order for a pet * @@ -283,7 +283,7 @@ class StoreApi /** - * getOrderById + * getOrderByIdWithHttpInfo * * Find purchase order by ID * @@ -377,7 +377,7 @@ class StoreApi /** - * deleteOrder + * deleteOrderWithHttpInfo * * Delete purchase order by ID * diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php index 588f2b0a2e1..98a26537f2a 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php @@ -108,7 +108,7 @@ class UserApi /** - * createUser + * createUserWithHttpInfo * * Create user * @@ -187,7 +187,7 @@ class UserApi /** - * createUsersWithArrayInput + * createUsersWithArrayInputWithHttpInfo * * Creates list of users with given input array * @@ -266,7 +266,7 @@ class UserApi /** - * createUsersWithListInput + * createUsersWithListInputWithHttpInfo * * Creates list of users with given input array * @@ -346,7 +346,7 @@ class UserApi /** - * loginUser + * loginUserWithHttpInfo * * Logs user into the system * @@ -435,7 +435,7 @@ class UserApi /** - * logoutUser + * logoutUserWithHttpInfo * * Logs out current logged in user session * @@ -509,7 +509,7 @@ class UserApi /** - * getUserByName + * getUserByNameWithHttpInfo * * Get user by user name * @@ -604,7 +604,7 @@ class UserApi /** - * updateUser + * updateUserWithHttpInfo * * Updated user * @@ -695,7 +695,7 @@ class UserApi /** - * deleteUser + * deleteUserWithHttpInfo * * Delete user * From 442f87c19a08b5c797ca60796d54fa3a2437fa18 Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 7 Dec 2015 00:42:25 +0800 Subject: [PATCH 06/17] minor style change for php functions --- .../src/main/resources/php/api.mustache | 4 +-- .../php/SwaggerClient-php/lib/Api/PetApi.php | 32 +++++++++---------- .../SwaggerClient-php/lib/Api/StoreApi.php | 16 +++++----- .../php/SwaggerClient-php/lib/Api/UserApi.php | 32 +++++++++---------- 4 files changed, 42 insertions(+), 42 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/php/api.mustache b/modules/swagger-codegen/src/main/resources/php/api.mustache index 0b28b2b4ca6..53a476b4061 100644 --- a/modules/swagger-codegen/src/main/resources/php/api.mustache +++ b/modules/swagger-codegen/src/main/resources/php/api.mustache @@ -100,7 +100,7 @@ use \{{invokerPackage}}\ObjectSerializer; {{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} * @throws \{{invokerPackage}}\ApiException on non-2xx response */ - public function {{operationId}} ({{#allParams}}${{paramName}}{{^required}}=null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) + public function {{operationId}}({{#allParams}}${{paramName}}{{^required}}=null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { list($response, $statusCode, $httpHeader) = $this->{{operationId}}WithHttpInfo ({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); return $response; @@ -116,7 +116,7 @@ use \{{invokerPackage}}\ObjectSerializer; {{/allParams}} * @return Array of {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}null{{/returnType}}, HTTP status code, HTTP response headers (array of strings) * @throws \{{invokerPackage}}\ApiException on non-2xx response */ - public function {{operationId}}WithHttpInfo ({{#allParams}}${{paramName}}{{^required}}=null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) + public function {{operationId}}WithHttpInfo({{#allParams}}${{paramName}}{{^required}}=null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { {{#allParams}}{{#required}} // verify the required parameter '{{paramName}}' is set 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 c5ac2e17eb9..ed73dd64dc8 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -100,7 +100,7 @@ class PetApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function updatePet ($body=null) + public function updatePet($body=null) { list($response, $statusCode, $httpHeader) = $this->updatePetWithHttpInfo ($body); return $response; @@ -116,7 +116,7 @@ class PetApi * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function updatePetWithHttpInfo ($body=null) + public function updatePetWithHttpInfo($body=null) { @@ -184,7 +184,7 @@ class PetApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function addPet ($body=null) + public function addPet($body=null) { list($response, $statusCode, $httpHeader) = $this->addPetWithHttpInfo ($body); return $response; @@ -200,7 +200,7 @@ class PetApi * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function addPetWithHttpInfo ($body=null) + public function addPetWithHttpInfo($body=null) { @@ -268,7 +268,7 @@ class PetApi * @return \Swagger\Client\Model\Pet[] * @throws \Swagger\Client\ApiException on non-2xx response */ - public function findPetsByStatus ($status=null) + public function findPetsByStatus($status=null) { list($response, $statusCode, $httpHeader) = $this->findPetsByStatusWithHttpInfo ($status); return $response; @@ -284,7 +284,7 @@ class PetApi * @return Array of \Swagger\Client\Model\Pet[], HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function findPetsByStatusWithHttpInfo ($status=null) + public function findPetsByStatusWithHttpInfo($status=null) { @@ -359,7 +359,7 @@ class PetApi * @return \Swagger\Client\Model\Pet[] * @throws \Swagger\Client\ApiException on non-2xx response */ - public function findPetsByTags ($tags=null) + public function findPetsByTags($tags=null) { list($response, $statusCode, $httpHeader) = $this->findPetsByTagsWithHttpInfo ($tags); return $response; @@ -375,7 +375,7 @@ class PetApi * @return Array of \Swagger\Client\Model\Pet[], HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function findPetsByTagsWithHttpInfo ($tags=null) + public function findPetsByTagsWithHttpInfo($tags=null) { @@ -450,7 +450,7 @@ class PetApi * @return \Swagger\Client\Model\Pet * @throws \Swagger\Client\ApiException on non-2xx response */ - public function getPetById ($pet_id) + public function getPetById($pet_id) { list($response, $statusCode, $httpHeader) = $this->getPetByIdWithHttpInfo ($pet_id); return $response; @@ -466,7 +466,7 @@ class PetApi * @return Array of \Swagger\Client\Model\Pet, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function getPetByIdWithHttpInfo ($pet_id) + public function getPetByIdWithHttpInfo($pet_id) { // verify the required parameter 'pet_id' is set @@ -553,7 +553,7 @@ class PetApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function updatePetWithForm ($pet_id, $name=null, $status=null) + public function updatePetWithForm($pet_id, $name=null, $status=null) { list($response, $statusCode, $httpHeader) = $this->updatePetWithFormWithHttpInfo ($pet_id, $name, $status); return $response; @@ -571,7 +571,7 @@ class PetApi * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function updatePetWithFormWithHttpInfo ($pet_id, $name=null, $status=null) + public function updatePetWithFormWithHttpInfo($pet_id, $name=null, $status=null) { // verify the required parameter 'pet_id' is set @@ -659,7 +659,7 @@ class PetApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function deletePet ($pet_id, $api_key=null) + public function deletePet($pet_id, $api_key=null) { list($response, $statusCode, $httpHeader) = $this->deletePetWithHttpInfo ($pet_id, $api_key); return $response; @@ -676,7 +676,7 @@ class PetApi * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function deletePetWithHttpInfo ($pet_id, $api_key=null) + public function deletePetWithHttpInfo($pet_id, $api_key=null) { // verify the required parameter 'pet_id' is set @@ -756,7 +756,7 @@ class PetApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function uploadFile ($pet_id, $additional_metadata=null, $file=null) + public function uploadFile($pet_id, $additional_metadata=null, $file=null) { list($response, $statusCode, $httpHeader) = $this->uploadFileWithHttpInfo ($pet_id, $additional_metadata, $file); return $response; @@ -774,7 +774,7 @@ class PetApi * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function uploadFileWithHttpInfo ($pet_id, $additional_metadata=null, $file=null) + public function uploadFileWithHttpInfo($pet_id, $additional_metadata=null, $file=null) { // verify the required parameter 'pet_id' is set diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php index 3deab979d41..34490783ffb 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php @@ -99,7 +99,7 @@ class StoreApi * @return map[string,int] * @throws \Swagger\Client\ApiException on non-2xx response */ - public function getInventory () + public function getInventory() { list($response, $statusCode, $httpHeader) = $this->getInventoryWithHttpInfo (); return $response; @@ -114,7 +114,7 @@ class StoreApi * @return Array of map[string,int], HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function getInventoryWithHttpInfo () + public function getInventoryWithHttpInfo() { @@ -188,7 +188,7 @@ class StoreApi * @return \Swagger\Client\Model\Order * @throws \Swagger\Client\ApiException on non-2xx response */ - public function placeOrder ($body=null) + public function placeOrder($body=null) { list($response, $statusCode, $httpHeader) = $this->placeOrderWithHttpInfo ($body); return $response; @@ -204,7 +204,7 @@ class StoreApi * @return Array of \Swagger\Client\Model\Order, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function placeOrderWithHttpInfo ($body=null) + public function placeOrderWithHttpInfo($body=null) { @@ -275,7 +275,7 @@ class StoreApi * @return \Swagger\Client\Model\Order * @throws \Swagger\Client\ApiException on non-2xx response */ - public function getOrderById ($order_id) + public function getOrderById($order_id) { list($response, $statusCode, $httpHeader) = $this->getOrderByIdWithHttpInfo ($order_id); return $response; @@ -291,7 +291,7 @@ class StoreApi * @return Array of \Swagger\Client\Model\Order, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function getOrderByIdWithHttpInfo ($order_id) + public function getOrderByIdWithHttpInfo($order_id) { // verify the required parameter 'order_id' is set @@ -369,7 +369,7 @@ class StoreApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function deleteOrder ($order_id) + public function deleteOrder($order_id) { list($response, $statusCode, $httpHeader) = $this->deleteOrderWithHttpInfo ($order_id); return $response; @@ -385,7 +385,7 @@ class StoreApi * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function deleteOrderWithHttpInfo ($order_id) + public function deleteOrderWithHttpInfo($order_id) { // verify the required parameter 'order_id' is set diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php index 98a26537f2a..2a19c2f7798 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php @@ -100,7 +100,7 @@ class UserApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function createUser ($body=null) + public function createUser($body=null) { list($response, $statusCode, $httpHeader) = $this->createUserWithHttpInfo ($body); return $response; @@ -116,7 +116,7 @@ class UserApi * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function createUserWithHttpInfo ($body=null) + public function createUserWithHttpInfo($body=null) { @@ -179,7 +179,7 @@ class UserApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function createUsersWithArrayInput ($body=null) + public function createUsersWithArrayInput($body=null) { list($response, $statusCode, $httpHeader) = $this->createUsersWithArrayInputWithHttpInfo ($body); return $response; @@ -195,7 +195,7 @@ class UserApi * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function createUsersWithArrayInputWithHttpInfo ($body=null) + public function createUsersWithArrayInputWithHttpInfo($body=null) { @@ -258,7 +258,7 @@ class UserApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function createUsersWithListInput ($body=null) + public function createUsersWithListInput($body=null) { list($response, $statusCode, $httpHeader) = $this->createUsersWithListInputWithHttpInfo ($body); return $response; @@ -274,7 +274,7 @@ class UserApi * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function createUsersWithListInputWithHttpInfo ($body=null) + public function createUsersWithListInputWithHttpInfo($body=null) { @@ -338,7 +338,7 @@ class UserApi * @return string * @throws \Swagger\Client\ApiException on non-2xx response */ - public function loginUser ($username=null, $password=null) + public function loginUser($username=null, $password=null) { list($response, $statusCode, $httpHeader) = $this->loginUserWithHttpInfo ($username, $password); return $response; @@ -355,7 +355,7 @@ class UserApi * @return Array of string, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function loginUserWithHttpInfo ($username=null, $password=null) + public function loginUserWithHttpInfo($username=null, $password=null) { @@ -427,7 +427,7 @@ class UserApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function logoutUser () + public function logoutUser() { list($response, $statusCode, $httpHeader) = $this->logoutUserWithHttpInfo (); return $response; @@ -442,7 +442,7 @@ class UserApi * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function logoutUserWithHttpInfo () + public function logoutUserWithHttpInfo() { @@ -501,7 +501,7 @@ class UserApi * @return \Swagger\Client\Model\User * @throws \Swagger\Client\ApiException on non-2xx response */ - public function getUserByName ($username) + public function getUserByName($username) { list($response, $statusCode, $httpHeader) = $this->getUserByNameWithHttpInfo ($username); return $response; @@ -517,7 +517,7 @@ class UserApi * @return Array of \Swagger\Client\Model\User, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function getUserByNameWithHttpInfo ($username) + public function getUserByNameWithHttpInfo($username) { // verify the required parameter 'username' is set @@ -596,7 +596,7 @@ class UserApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function updateUser ($username, $body=null) + public function updateUser($username, $body=null) { list($response, $statusCode, $httpHeader) = $this->updateUserWithHttpInfo ($username, $body); return $response; @@ -613,7 +613,7 @@ class UserApi * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function updateUserWithHttpInfo ($username, $body=null) + public function updateUserWithHttpInfo($username, $body=null) { // verify the required parameter 'username' is set @@ -687,7 +687,7 @@ class UserApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function deleteUser ($username) + public function deleteUser($username) { list($response, $statusCode, $httpHeader) = $this->deleteUserWithHttpInfo ($username); return $response; @@ -703,7 +703,7 @@ class UserApi * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function deleteUserWithHttpInfo ($username) + public function deleteUserWithHttpInfo($username) { // verify the required parameter 'username' is set From 340e60002e023e9ade296b1015345cf6544d12da Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 7 Dec 2015 00:52:30 +0800 Subject: [PATCH 07/17] more style change for php client --- .../src/main/resources/php/ApiClient.mustache | 20 +++--- .../resources/php/ObjectSerializer.mustache | 6 +- .../src/main/resources/php/api.mustache | 9 ++- .../php/SwaggerClient-php/lib/Api/PetApi.php | 68 ++++++++----------- .../SwaggerClient-php/lib/Api/StoreApi.php | 24 +++---- .../php/SwaggerClient-php/lib/Api/UserApi.php | 60 +++++++--------- .../php/SwaggerClient-php/lib/ApiClient.php | 20 +++--- .../lib/ObjectSerializer.php | 6 +- 8 files changed, 96 insertions(+), 117 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache index 86998fd16d0..be18e221972 100644 --- a/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache @@ -131,7 +131,7 @@ class ApiClient * @throws \{{invokerPackage}}\ApiException on a non 2xx response * @return mixed */ - public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType=null) + public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType = null) { $headers = array(); @@ -149,7 +149,7 @@ class ApiClient // form data if ($postData and in_array('Content-Type: application/x-www-form-urlencoded', $headers)) { $postData = http_build_query($postData); - } else if ((is_object($postData) or is_array($postData)) and !in_array('Content-Type: multipart/form-data', $headers)) { // json model + } elseif ((is_object($postData) or is_array($postData)) and !in_array('Content-Type: multipart/form-data', $headers)) { // json model $postData = json_encode($this->serializer->sanitizeForSerialization($postData)); } @@ -160,7 +160,7 @@ class ApiClient if ($this->config->getCurlTimeout() != 0) { curl_setopt($curl, CURLOPT_TIMEOUT, $this->config->getCurlTimeout()); } - // return the result on success, rather than just TRUE + // return the result on success, rather than just true curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); @@ -178,21 +178,21 @@ class ApiClient if ($method == self::$POST) { curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); - } else if ($method == self::$HEAD) { + } elseif ($method == self::$HEAD) { curl_setopt($curl, CURLOPT_NOBODY, true); - } else if ($method == self::$OPTIONS) { + } elseif ($method == self::$OPTIONS) { curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "OPTIONS"); curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); - } else if ($method == self::$PATCH) { + } elseif ($method == self::$PATCH) { curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH"); curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); - } else if ($method == self::$PUT) { + } elseif ($method == self::$PUT) { curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); - } else if ($method == self::$DELETE) { + } elseif ($method == self::$DELETE) { curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE"); curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); - } else if ($method != self::$GET) { + } elseif ($method != self::$GET) { throw new ApiException('Method ' . $method . ' is not recognized.'); } curl_setopt($curl, CURLOPT_URL, $url); @@ -228,7 +228,7 @@ class ApiClient // Handle the response if ($response_info['http_code'] == 0) { throw new ApiException("API call to $url timed out: ".serialize($response_info), 0, null, null); - } else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) { + } elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) { // return raw body if response is a file if ($responseType == '\SplFileObject') { return array($http_body, $response_info['http_code'], $http_header); diff --git a/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache b/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache index 54fb66a9543..133c1b1f454 100644 --- a/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache +++ b/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache @@ -56,14 +56,14 @@ class ObjectSerializer { if (is_scalar($data) || null === $data) { $sanitized = $data; - } else if ($data instanceof \DateTime) { + } elseif ($data instanceof \DateTime) { $sanitized = $data->format(\DateTime::ISO8601); - } else if (is_array($data)) { + } elseif (is_array($data)) { foreach ($data as $property => $value) { $data[$property] = $this->sanitizeForSerialization($value); } $sanitized = $data; - } else if (is_object($data)) { + } elseif (is_object($data)) { $values = array(); foreach (array_keys($data::$swaggerTypes) as $property) { $getter = $data::$getters[$property]; diff --git a/modules/swagger-codegen/src/main/resources/php/api.mustache b/modules/swagger-codegen/src/main/resources/php/api.mustache index 53a476b4061..22ae27fc77d 100644 --- a/modules/swagger-codegen/src/main/resources/php/api.mustache +++ b/modules/swagger-codegen/src/main/resources/php/api.mustache @@ -100,7 +100,7 @@ use \{{invokerPackage}}\ObjectSerializer; {{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} * @throws \{{invokerPackage}}\ApiException on non-2xx response */ - public function {{operationId}}({{#allParams}}${{paramName}}{{^required}}=null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) + public function {{operationId}}({{#allParams}}${{paramName}}{{^required}} = null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { list($response, $statusCode, $httpHeader) = $this->{{operationId}}WithHttpInfo ({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); return $response; @@ -116,7 +116,7 @@ use \{{invokerPackage}}\ObjectSerializer; {{/allParams}} * @return Array of {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}null{{/returnType}}, HTTP status code, HTTP response headers (array of strings) * @throws \{{invokerPackage}}\ApiException on non-2xx response */ - public function {{operationId}}WithHttpInfo({{#allParams}}${{paramName}}{{^required}}=null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) + public function {{operationId}}WithHttpInfo({{#allParams}}${{paramName}}{{^required}} = null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { {{#allParams}}{{#required}} // verify the required parameter '{{paramName}}' is set @@ -178,7 +178,7 @@ use \{{invokerPackage}}\ObjectSerializer; // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { + } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } {{#authMethods}}{{#isApiKey}} @@ -196,8 +196,7 @@ use \{{invokerPackage}}\ObjectSerializer; }{{/isOAuth}} {{/authMethods}} // make the API Call - try - { + try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, 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 ed73dd64dc8..18aeba64072 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -100,7 +100,7 @@ class PetApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function updatePet($body=null) + public function updatePet($body = null) { list($response, $statusCode, $httpHeader) = $this->updatePetWithHttpInfo ($body); return $response; @@ -116,7 +116,7 @@ class PetApi * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function updatePetWithHttpInfo($body=null) + public function updatePetWithHttpInfo($body = null) { @@ -147,7 +147,7 @@ class PetApi // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { + } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } @@ -157,8 +157,7 @@ class PetApi } // make the API Call - try - { + try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, @@ -184,7 +183,7 @@ class PetApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function addPet($body=null) + public function addPet($body = null) { list($response, $statusCode, $httpHeader) = $this->addPetWithHttpInfo ($body); return $response; @@ -200,7 +199,7 @@ class PetApi * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function addPetWithHttpInfo($body=null) + public function addPetWithHttpInfo($body = null) { @@ -231,7 +230,7 @@ class PetApi // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { + } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } @@ -241,8 +240,7 @@ class PetApi } // make the API Call - try - { + try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, @@ -268,7 +266,7 @@ class PetApi * @return \Swagger\Client\Model\Pet[] * @throws \Swagger\Client\ApiException on non-2xx response */ - public function findPetsByStatus($status=null) + public function findPetsByStatus($status = null) { list($response, $statusCode, $httpHeader) = $this->findPetsByStatusWithHttpInfo ($status); return $response; @@ -284,7 +282,7 @@ class PetApi * @return Array of \Swagger\Client\Model\Pet[], HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function findPetsByStatusWithHttpInfo($status=null) + public function findPetsByStatusWithHttpInfo($status = null) { @@ -314,7 +312,7 @@ class PetApi // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { + } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } @@ -324,8 +322,7 @@ class PetApi } // make the API Call - try - { + try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, @@ -359,7 +356,7 @@ class PetApi * @return \Swagger\Client\Model\Pet[] * @throws \Swagger\Client\ApiException on non-2xx response */ - public function findPetsByTags($tags=null) + public function findPetsByTags($tags = null) { list($response, $statusCode, $httpHeader) = $this->findPetsByTagsWithHttpInfo ($tags); return $response; @@ -375,7 +372,7 @@ class PetApi * @return Array of \Swagger\Client\Model\Pet[], HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function findPetsByTagsWithHttpInfo($tags=null) + public function findPetsByTagsWithHttpInfo($tags = null) { @@ -405,7 +402,7 @@ class PetApi // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { + } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } @@ -415,8 +412,7 @@ class PetApi } // make the API Call - try - { + try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, @@ -504,7 +500,7 @@ class PetApi // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { + } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } @@ -516,8 +512,7 @@ class PetApi // make the API Call - try - { + try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, @@ -553,7 +548,7 @@ class PetApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function updatePetWithForm($pet_id, $name=null, $status=null) + public function updatePetWithForm($pet_id, $name = null, $status = null) { list($response, $statusCode, $httpHeader) = $this->updatePetWithFormWithHttpInfo ($pet_id, $name, $status); return $response; @@ -571,7 +566,7 @@ class PetApi * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function updatePetWithFormWithHttpInfo($pet_id, $name=null, $status=null) + public function updatePetWithFormWithHttpInfo($pet_id, $name = null, $status = null) { // verify the required parameter 'pet_id' is set @@ -621,7 +616,7 @@ class PetApi // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { + } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } @@ -631,8 +626,7 @@ class PetApi } // make the API Call - try - { + try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, @@ -659,7 +653,7 @@ class PetApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function deletePet($pet_id, $api_key=null) + public function deletePet($pet_id, $api_key = null) { list($response, $statusCode, $httpHeader) = $this->deletePetWithHttpInfo ($pet_id, $api_key); return $response; @@ -676,7 +670,7 @@ class PetApi * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function deletePetWithHttpInfo($pet_id, $api_key=null) + public function deletePetWithHttpInfo($pet_id, $api_key = null) { // verify the required parameter 'pet_id' is set @@ -717,7 +711,7 @@ class PetApi // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { + } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } @@ -727,8 +721,7 @@ class PetApi } // make the API Call - try - { + try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, @@ -756,7 +749,7 @@ class PetApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function uploadFile($pet_id, $additional_metadata=null, $file=null) + public function uploadFile($pet_id, $additional_metadata = null, $file = null) { list($response, $statusCode, $httpHeader) = $this->uploadFileWithHttpInfo ($pet_id, $additional_metadata, $file); return $response; @@ -774,7 +767,7 @@ class PetApi * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function uploadFileWithHttpInfo($pet_id, $additional_metadata=null, $file=null) + public function uploadFileWithHttpInfo($pet_id, $additional_metadata = null, $file = null) { // verify the required parameter 'pet_id' is set @@ -830,7 +823,7 @@ class PetApi // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { + } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } @@ -840,8 +833,7 @@ class PetApi } // make the API Call - try - { + try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php index 34490783ffb..4539aeeeab4 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php @@ -141,7 +141,7 @@ class StoreApi // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { + } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } @@ -153,8 +153,7 @@ class StoreApi // make the API Call - try - { + try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, @@ -188,7 +187,7 @@ class StoreApi * @return \Swagger\Client\Model\Order * @throws \Swagger\Client\ApiException on non-2xx response */ - public function placeOrder($body=null) + public function placeOrder($body = null) { list($response, $statusCode, $httpHeader) = $this->placeOrderWithHttpInfo ($body); return $response; @@ -204,7 +203,7 @@ class StoreApi * @return Array of \Swagger\Client\Model\Order, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function placeOrderWithHttpInfo($body=null) + public function placeOrderWithHttpInfo($body = null) { @@ -235,13 +234,12 @@ class StoreApi // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { + } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } // make the API Call - try - { + try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, @@ -329,13 +327,12 @@ class StoreApi // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { + } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } // make the API Call - try - { + try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, @@ -423,13 +420,12 @@ class StoreApi // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { + } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } // make the API Call - try - { + try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php index 2a19c2f7798..f200ff51d2a 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php @@ -100,7 +100,7 @@ class UserApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function createUser($body=null) + public function createUser($body = null) { list($response, $statusCode, $httpHeader) = $this->createUserWithHttpInfo ($body); return $response; @@ -116,7 +116,7 @@ class UserApi * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function createUserWithHttpInfo($body=null) + public function createUserWithHttpInfo($body = null) { @@ -147,13 +147,12 @@ class UserApi // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { + } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } // make the API Call - try - { + try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, @@ -179,7 +178,7 @@ class UserApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function createUsersWithArrayInput($body=null) + public function createUsersWithArrayInput($body = null) { list($response, $statusCode, $httpHeader) = $this->createUsersWithArrayInputWithHttpInfo ($body); return $response; @@ -195,7 +194,7 @@ class UserApi * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function createUsersWithArrayInputWithHttpInfo($body=null) + public function createUsersWithArrayInputWithHttpInfo($body = null) { @@ -226,13 +225,12 @@ class UserApi // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { + } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } // make the API Call - try - { + try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, @@ -258,7 +256,7 @@ class UserApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function createUsersWithListInput($body=null) + public function createUsersWithListInput($body = null) { list($response, $statusCode, $httpHeader) = $this->createUsersWithListInputWithHttpInfo ($body); return $response; @@ -274,7 +272,7 @@ class UserApi * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function createUsersWithListInputWithHttpInfo($body=null) + public function createUsersWithListInputWithHttpInfo($body = null) { @@ -305,13 +303,12 @@ class UserApi // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { + } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } // make the API Call - try - { + try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, @@ -338,7 +335,7 @@ class UserApi * @return string * @throws \Swagger\Client\ApiException on non-2xx response */ - public function loginUser($username=null, $password=null) + public function loginUser($username = null, $password = null) { list($response, $statusCode, $httpHeader) = $this->loginUserWithHttpInfo ($username, $password); return $response; @@ -355,7 +352,7 @@ class UserApi * @return Array of string, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function loginUserWithHttpInfo($username=null, $password=null) + public function loginUserWithHttpInfo($username = null, $password = null) { @@ -388,13 +385,12 @@ class UserApi // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { + } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } // make the API Call - try - { + try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, @@ -469,13 +465,12 @@ class UserApi // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { + } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } // make the API Call - try - { + try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, @@ -555,13 +550,12 @@ class UserApi // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { + } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } // make the API Call - try - { + try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, @@ -596,7 +590,7 @@ class UserApi * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ - public function updateUser($username, $body=null) + public function updateUser($username, $body = null) { list($response, $statusCode, $httpHeader) = $this->updateUserWithHttpInfo ($username, $body); return $response; @@ -613,7 +607,7 @@ class UserApi * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ - public function updateUserWithHttpInfo($username, $body=null) + public function updateUserWithHttpInfo($username, $body = null) { // verify the required parameter 'username' is set @@ -655,13 +649,12 @@ class UserApi // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { + } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } // make the API Call - try - { + try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, @@ -741,13 +734,12 @@ class UserApi // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { + } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } // make the API Call - try - { + try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, $method, $queryParams, $httpBody, diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php b/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php index 2f3aacd1ffd..8730a8c0601 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php @@ -131,7 +131,7 @@ class ApiClient * @throws \Swagger\Client\ApiException on a non 2xx response * @return mixed */ - public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType=null) + public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType = null) { $headers = array(); @@ -149,7 +149,7 @@ class ApiClient // form data if ($postData and in_array('Content-Type: application/x-www-form-urlencoded', $headers)) { $postData = http_build_query($postData); - } else if ((is_object($postData) or is_array($postData)) and !in_array('Content-Type: multipart/form-data', $headers)) { // json model + } elseif ((is_object($postData) or is_array($postData)) and !in_array('Content-Type: multipart/form-data', $headers)) { // json model $postData = json_encode($this->serializer->sanitizeForSerialization($postData)); } @@ -160,7 +160,7 @@ class ApiClient if ($this->config->getCurlTimeout() != 0) { curl_setopt($curl, CURLOPT_TIMEOUT, $this->config->getCurlTimeout()); } - // return the result on success, rather than just TRUE + // return the result on success, rather than just true curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); @@ -178,21 +178,21 @@ class ApiClient if ($method == self::$POST) { curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); - } else if ($method == self::$HEAD) { + } elseif ($method == self::$HEAD) { curl_setopt($curl, CURLOPT_NOBODY, true); - } else if ($method == self::$OPTIONS) { + } elseif ($method == self::$OPTIONS) { curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "OPTIONS"); curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); - } else if ($method == self::$PATCH) { + } elseif ($method == self::$PATCH) { curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH"); curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); - } else if ($method == self::$PUT) { + } elseif ($method == self::$PUT) { curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); - } else if ($method == self::$DELETE) { + } elseif ($method == self::$DELETE) { curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE"); curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); - } else if ($method != self::$GET) { + } elseif ($method != self::$GET) { throw new ApiException('Method ' . $method . ' is not recognized.'); } curl_setopt($curl, CURLOPT_URL, $url); @@ -228,7 +228,7 @@ class ApiClient // Handle the response if ($response_info['http_code'] == 0) { throw new ApiException("API call to $url timed out: ".serialize($response_info), 0, null, null); - } else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) { + } elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) { // return raw body if response is a file if ($responseType == '\SplFileObject') { return array($http_body, $response_info['http_code'], $http_header); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php index 22d03030fb3..cc023b61bd2 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php @@ -56,14 +56,14 @@ class ObjectSerializer { if (is_scalar($data) || null === $data) { $sanitized = $data; - } else if ($data instanceof \DateTime) { + } elseif ($data instanceof \DateTime) { $sanitized = $data->format(\DateTime::ISO8601); - } else if (is_array($data)) { + } elseif (is_array($data)) { foreach ($data as $property => $value) { $data[$property] = $this->sanitizeForSerialization($value); } $sanitized = $data; - } else if (is_object($data)) { + } elseif (is_object($data)) { $values = array(); foreach (array_keys($data::$swaggerTypes) as $property) { $getter = $data::$getters[$property]; From b1bc75189aa37dc95b93f26f827be725a18246c0 Mon Sep 17 00:00:00 2001 From: xhh Date: Sat, 5 Dec 2015 20:34:50 +0800 Subject: [PATCH 08/17] Add WithHttpInfo API methods to Java okhttp-gson client to allow accessing response status code and headers and removed the methods of recording last response info from ApiClient. --- .../codegen/languages/JavaClientCodegen.java | 1 + .../libraries/okhttp-gson/ApiClient.mustache | 34 +---- .../okhttp-gson/ApiResponse.mustache | 32 +++++ .../Java/libraries/okhttp-gson/api.mustache | 14 +- .../java/io/swagger/client/ApiClient.java | 36 ++--- .../java/io/swagger/client/ApiResponse.java | 32 +++++ .../java/io/swagger/client/api/PetApi.java | 133 +++++++++++++++--- .../java/io/swagger/client/api/StoreApi.java | 59 ++++++-- .../java/io/swagger/client/api/UserApi.java | 130 ++++++++++++++--- .../io/swagger/petstore/test/PetApiTest.java | 21 ++- 10 files changed, 378 insertions(+), 114 deletions(-) create mode 100644 modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiResponse.mustache create mode 100644 samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiResponse.java diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java index 0aba8c2c9d1..67a746d4afb 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java @@ -232,6 +232,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { if ("okhttp-gson".equals(getLibrary())) { // the "okhttp-gson" library template requires "ApiCallback.mustache" for async call supportingFiles.add(new SupportingFile("ApiCallback.mustache", invokerFolder, "ApiCallback.java")); + supportingFiles.add(new SupportingFile("ApiResponse.mustache", invokerFolder, "ApiResponse.java")); supportingFiles.add(new SupportingFile("ProgressRequestBody.mustache", invokerFolder, "ProgressRequestBody.java")); supportingFiles.add(new SupportingFile("ProgressResponseBody.mustache", invokerFolder, "ProgressResponseBody.java")); // "build.sbt" is for development with SBT diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache index cef9a843347..7b21d760f56 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache @@ -104,9 +104,6 @@ public class ApiClient { private Map authentications; - private int statusCode; - private Map> responseHeaders; - private DateFormat dateFormat; private DateFormat datetimeFormat; private boolean lenientDatetimeFormat; @@ -177,24 +174,6 @@ public class ApiClient { return this; } - /** - * Gets the status code of the previous request. - * NOTE: Status code of last async response is not recorded here, it is - * passed to the callback methods instead. - */ - public int getStatusCode() { - return statusCode; - } - - /** - * Gets the response headers of the previous request. - * NOTE: Headers of last async response is not recorded here, it is passed - * to callback methods instead. - */ - public Map> getResponseHeaders() { - return responseHeaders; - } - public boolean isVerifyingSsl() { return verifyingSsl; } @@ -731,7 +710,7 @@ public class ApiClient { /** * @see #execute(Call, Type) */ - public T execute(Call call) throws ApiException { + public ApiResponse execute(Call call) throws ApiException { return execute(call, null); } @@ -740,14 +719,15 @@ public class ApiClient { * * @param returnType The return type used to deserialize HTTP response body * @param The return type corresponding to (same with) returnType - * @return The Java object deserialized from response body. Returns null if returnType is null. + * @return ApiResponse object containing response status, headers and + * data, which is a Java object deserialized from response body and would be null + * when returnType is null. */ - public T execute(Call call, Type returnType) throws ApiException { + public ApiResponse execute(Call call, Type returnType) throws ApiException { try { Response response = call.execute(); - this.statusCode = response.code(); - this.responseHeaders = response.headers().toMultimap(); - return handleResponse(response, returnType); + T data = handleResponse(response, returnType); + return new ApiResponse(response.code(), response.headers().toMultimap(), data); } catch (IOException e) { throw new ApiException(e); } diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiResponse.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiResponse.mustache new file mode 100644 index 00000000000..945de39da70 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiResponse.mustache @@ -0,0 +1,32 @@ +package {{invokerPackage}}; + +import java.util.List; +import java.util.Map; + +public class ApiResponse { + final private int statusCode; + final private Map> headers; + final private T data; + + public ApiResponse(int statusCode, Map> headers) { + this(statusCode, headers, null); + } + + public ApiResponse(int statusCode, Map> headers, T data) { + this.statusCode = statusCode; + this.headers = headers; + this.data = data; + } + + public int getStatusCode() { + return statusCode; + } + + public Map> getHeaders() { + return headers; + } + + public T getData() { + return data; + } +} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache index a1a4c9f8fb4..da145d08df2 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache @@ -3,6 +3,7 @@ package {{package}}; import {{invokerPackage}}.ApiCallback; import {{invokerPackage}}.ApiClient; import {{invokerPackage}}.ApiException; +import {{invokerPackage}}.ApiResponse; import {{invokerPackage}}.Configuration; import {{invokerPackage}}.Pair; import {{invokerPackage}}.ProgressRequestBody; @@ -106,9 +107,20 @@ public class {{classname}} { * @return {{{returnType}}}{{/returnType}} */ public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException { + {{#returnType}}ApiResponse<{{{returnType}}}> {{localVariablePrefix}}resp = {{/returnType}}{{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} + return {{localVariablePrefix}}resp.getData();{{/returnType}} + } + + /** + * {{summary}} + * {{notes}}{{#allParams}} + * @param {{paramName}} {{description}}{{/allParams}} + * @return ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> + */ + public ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException { Call {{localVariablePrefix}}call = {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}null, null); {{#returnType}}Type {{localVariablePrefix}}returnType = new TypeToken<{{{returnType}}}>(){}.getType(); - return {{localVariablePrefix}}apiClient.execute({{localVariablePrefix}}call, {{localVariablePrefix}}returnType);{{/returnType}}{{^returnType}}{{localVariablePrefix}}apiClient.execute({{localVariablePrefix}}call);{{/returnType}} + return {{localVariablePrefix}}apiClient.execute({{localVariablePrefix}}call, {{localVariablePrefix}}returnType);{{/returnType}}{{^returnType}}return {{localVariablePrefix}}apiClient.execute({{localVariablePrefix}}call);{{/returnType}} } /** diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java index 8d38c18e907..8a75219bb53 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java @@ -104,9 +104,6 @@ public class ApiClient { private Map authentications; - private int statusCode; - private Map> responseHeaders; - private DateFormat dateFormat; private DateFormat datetimeFormat; private boolean lenientDatetimeFormat; @@ -143,8 +140,8 @@ public class ApiClient { // Setup authentications (key: authentication name, value: authentication). authentications = new HashMap(); - authentications.put("api_key", new ApiKeyAuth("header", "api_key")); authentications.put("petstore_auth", new OAuth()); + authentications.put("api_key", new ApiKeyAuth("header", "api_key")); // Prevent the authentications from being modified. authentications = Collections.unmodifiableMap(authentications); } @@ -176,24 +173,6 @@ public class ApiClient { return this; } - /** - * Gets the status code of the previous request. - * NOTE: Status code of last async response is not recorded here, it is - * passed to the callback methods instead. - */ - public int getStatusCode() { - return statusCode; - } - - /** - * Gets the response headers of the previous request. - * NOTE: Headers of last async response is not recorded here, it is passed - * to callback methods instead. - */ - public Map> getResponseHeaders() { - return responseHeaders; - } - public boolean isVerifyingSsl() { return verifyingSsl; } @@ -730,7 +709,7 @@ public class ApiClient { /** * @see #execute(Call, Type) */ - public T execute(Call call) throws ApiException { + public ApiResponse execute(Call call) throws ApiException { return execute(call, null); } @@ -739,14 +718,15 @@ public class ApiClient { * * @param returnType The return type used to deserialize HTTP response body * @param The return type corresponding to (same with) returnType - * @return The Java object deserialized from response body. Returns null if returnType is null. + * @return ApiResponse object containing response status, headers and + * data, which is a Java object deserialized from response body and would be null + * when returnType is null. */ - public T execute(Call call, Type returnType) throws ApiException { + public ApiResponse execute(Call call, Type returnType) throws ApiException { try { Response response = call.execute(); - this.statusCode = response.code(); - this.responseHeaders = response.headers().toMultimap(); - return handleResponse(response, returnType); + T data = handleResponse(response, returnType); + return new ApiResponse(response.code(), response.headers().toMultimap(), data); } catch (IOException e) { throw new ApiException(e); } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiResponse.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiResponse.java new file mode 100644 index 00000000000..fbe22e077b8 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiResponse.java @@ -0,0 +1,32 @@ +package io.swagger.client; + +import java.util.List; +import java.util.Map; + +public class ApiResponse { + final private int statusCode; + final private Map> headers; + final private T data; + + public ApiResponse(int statusCode, Map> headers) { + this(statusCode, headers, null); + } + + public ApiResponse(int statusCode, Map> headers, T data) { + this.statusCode = statusCode; + this.headers = headers; + this.data = data; + } + + public int getStatusCode() { + return statusCode; + } + + public Map> getHeaders() { + return headers; + } + + public T getData() { + return data; + } +} diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java index cce05b29a3a..e880e3f9fbf 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java @@ -3,6 +3,7 @@ package io.swagger.client.api; import io.swagger.client.ApiCallback; import io.swagger.client.ApiClient; import io.swagger.client.ApiException; +import io.swagger.client.ApiResponse; import io.swagger.client.Configuration; import io.swagger.client.Pair; import io.swagger.client.ProgressRequestBody; @@ -90,8 +91,18 @@ public class PetApi { * @param body Pet object that needs to be added to the store */ public void updatePet(Pet body) throws ApiException { + updatePetWithHttpInfo(body); + } + + /** + * Update an existing pet + * + * @param body Pet object that needs to be added to the store + * @return ApiResponse + */ + public ApiResponse updatePetWithHttpInfo(Pet body) throws ApiException { Call call = updatePetCall(body, null, null); - apiClient.execute(call); + return apiClient.execute(call); } /** @@ -106,7 +117,7 @@ public class PetApi { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - if(callback != null) { + if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { @@ -175,8 +186,18 @@ public class PetApi { * @param body Pet object that needs to be added to the store */ public void addPet(Pet body) throws ApiException { + addPetWithHttpInfo(body); + } + + /** + * Add a new pet to the store + * + * @param body Pet object that needs to be added to the store + * @return ApiResponse + */ + public ApiResponse addPetWithHttpInfo(Pet body) throws ApiException { Call call = addPetCall(body, null, null); - apiClient.execute(call); + return apiClient.execute(call); } /** @@ -191,7 +212,7 @@ public class PetApi { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - if(callback != null) { + if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { @@ -263,6 +284,17 @@ public class PetApi { * @return List */ public List findPetsByStatus(List status) throws ApiException { + ApiResponse> resp = findPetsByStatusWithHttpInfo(status); + return resp.getData(); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma seperated strings + * @param status Status values that need to be considered for filter + * @return ApiResponse> + */ + public ApiResponse> findPetsByStatusWithHttpInfo(List status) throws ApiException { Call call = findPetsByStatusCall(status, null, null); Type returnType = new TypeToken>(){}.getType(); return apiClient.execute(call, returnType); @@ -280,7 +312,7 @@ public class PetApi { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - if(callback != null) { + if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { @@ -353,6 +385,17 @@ public class PetApi { * @return List */ public List findPetsByTags(List tags) throws ApiException { + ApiResponse> resp = findPetsByTagsWithHttpInfo(tags); + return resp.getData(); + } + + /** + * Finds Pets by tags + * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by + * @return ApiResponse> + */ + public ApiResponse> findPetsByTagsWithHttpInfo(List tags) throws ApiException { Call call = findPetsByTagsCall(tags, null, null); Type returnType = new TypeToken>(){}.getType(); return apiClient.execute(call, returnType); @@ -370,7 +413,7 @@ public class PetApi { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - if(callback != null) { + if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { @@ -447,6 +490,17 @@ public class PetApi { * @return Pet */ public Pet getPetById(Long petId) throws ApiException { + ApiResponse resp = getPetByIdWithHttpInfo(petId); + return resp.getData(); + } + + /** + * Find pet by ID + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched + * @return ApiResponse + */ + public ApiResponse getPetByIdWithHttpInfo(Long petId) throws ApiException { Call call = getPetByIdCall(petId, null, null); Type returnType = new TypeToken(){}.getType(); return apiClient.execute(call, returnType); @@ -464,7 +518,7 @@ public class PetApi { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - if(callback != null) { + if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { @@ -487,7 +541,7 @@ public class PetApi { } /* Build call for updatePetWithForm */ - private Call updatePetWithFormCall(String petId,String name,String status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + private Call updatePetWithFormCall(String petId, String name, String status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object postBody = null; // verify the required parameter 'petId' is set @@ -546,8 +600,20 @@ public class PetApi { * @param status Updated status of the pet */ public void updatePetWithForm(String petId, String name, String status) throws ApiException { - Call call = updatePetWithFormCall(petId,name,status, null, null); - apiClient.execute(call); + updatePetWithFormWithHttpInfo(petId, name, status); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated + * @param name Updated name of the pet + * @param status Updated status of the pet + * @return ApiResponse + */ + public ApiResponse updatePetWithFormWithHttpInfo(String petId, String name, String status) throws ApiException { + Call call = updatePetWithFormCall(petId, name, status, null, null); + return apiClient.execute(call); } /** @@ -564,7 +630,7 @@ public class PetApi { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - if(callback != null) { + if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { @@ -580,13 +646,13 @@ public class PetApi { }; } - Call call = updatePetWithFormCall(petId,name,status, progressListener, progressRequestListener); + Call call = updatePetWithFormCall(petId, name, status, progressListener, progressRequestListener); apiClient.executeAsync(call, callback); return call; } /* Build call for deletePet */ - private Call deletePetCall(Long petId,String apiKey, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + private Call deletePetCall(Long petId, String apiKey, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object postBody = null; // verify the required parameter 'petId' is set @@ -642,8 +708,19 @@ public class PetApi { * @param apiKey */ public void deletePet(Long petId, String apiKey) throws ApiException { - Call call = deletePetCall(petId,apiKey, null, null); - apiClient.execute(call); + deletePetWithHttpInfo(petId, apiKey); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete + * @param apiKey + * @return ApiResponse + */ + public ApiResponse deletePetWithHttpInfo(Long petId, String apiKey) throws ApiException { + Call call = deletePetCall(petId, apiKey, null, null); + return apiClient.execute(call); } /** @@ -659,7 +736,7 @@ public class PetApi { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - if(callback != null) { + if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { @@ -675,13 +752,13 @@ public class PetApi { }; } - Call call = deletePetCall(petId,apiKey, progressListener, progressRequestListener); + Call call = deletePetCall(petId, apiKey, progressListener, progressRequestListener); apiClient.executeAsync(call, callback); return call; } /* Build call for uploadFile */ - private Call uploadFileCall(Long petId,String additionalMetadata,File file, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + private Call uploadFileCall(Long petId, String additionalMetadata, File file, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object postBody = null; // verify the required parameter 'petId' is set @@ -740,8 +817,20 @@ public class PetApi { * @param file file to upload */ public void uploadFile(Long petId, String additionalMetadata, File file) throws ApiException { - Call call = uploadFileCall(petId,additionalMetadata,file, null, null); - apiClient.execute(call); + uploadFileWithHttpInfo(petId, additionalMetadata, file); + } + + /** + * uploads an image + * + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + * @return ApiResponse + */ + public ApiResponse uploadFileWithHttpInfo(Long petId, String additionalMetadata, File file) throws ApiException { + Call call = uploadFileCall(petId, additionalMetadata, file, null, null); + return apiClient.execute(call); } /** @@ -758,7 +847,7 @@ public class PetApi { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - if(callback != null) { + if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { @@ -774,7 +863,7 @@ public class PetApi { }; } - Call call = uploadFileCall(petId,additionalMetadata,file, progressListener, progressRequestListener); + Call call = uploadFileCall(petId, additionalMetadata, file, progressListener, progressRequestListener); apiClient.executeAsync(call, callback); return call; } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java index 551fe0fbfc2..3e06890a81c 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java @@ -3,6 +3,7 @@ package io.swagger.client.api; import io.swagger.client.ApiCallback; import io.swagger.client.ApiClient; import io.swagger.client.ApiException; +import io.swagger.client.ApiResponse; import io.swagger.client.Configuration; import io.swagger.client.Pair; import io.swagger.client.ProgressRequestBody; @@ -43,7 +44,7 @@ public class StoreApi { /* Build call for getInventory */ - private Call getInventoryCall( final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + private Call getInventoryCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object postBody = null; @@ -90,7 +91,17 @@ public class StoreApi { * @return Map */ public Map getInventory() throws ApiException { - Call call = getInventoryCall( null, null); + ApiResponse> resp = getInventoryWithHttpInfo(); + return resp.getData(); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @return ApiResponse> + */ + public ApiResponse> getInventoryWithHttpInfo() throws ApiException { + Call call = getInventoryCall(null, null); Type returnType = new TypeToken>(){}.getType(); return apiClient.execute(call, returnType); } @@ -106,7 +117,7 @@ public class StoreApi { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - if(callback != null) { + if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { @@ -122,7 +133,7 @@ public class StoreApi { }; } - Call call = getInventoryCall( progressListener, progressRequestListener); + Call call = getInventoryCall(progressListener, progressRequestListener); Type returnType = new TypeToken>(){}.getType(); apiClient.executeAsync(call, returnType, callback); return call; @@ -177,6 +188,17 @@ public class StoreApi { * @return Order */ public Order placeOrder(Order body) throws ApiException { + ApiResponse resp = placeOrderWithHttpInfo(body); + return resp.getData(); + } + + /** + * Place an order for a pet + * + * @param body order placed for purchasing the pet + * @return ApiResponse + */ + public ApiResponse placeOrderWithHttpInfo(Order body) throws ApiException { Call call = placeOrderCall(body, null, null); Type returnType = new TypeToken(){}.getType(); return apiClient.execute(call, returnType); @@ -194,7 +216,7 @@ public class StoreApi { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - if(callback != null) { + if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { @@ -271,6 +293,17 @@ public class StoreApi { * @return Order */ public Order getOrderById(String orderId) throws ApiException { + ApiResponse resp = getOrderByIdWithHttpInfo(orderId); + return resp.getData(); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @param orderId ID of pet that needs to be fetched + * @return ApiResponse + */ + public ApiResponse getOrderByIdWithHttpInfo(String orderId) throws ApiException { Call call = getOrderByIdCall(orderId, null, null); Type returnType = new TypeToken(){}.getType(); return apiClient.execute(call, returnType); @@ -288,7 +321,7 @@ public class StoreApi { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - if(callback != null) { + if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { @@ -364,8 +397,18 @@ public class StoreApi { * @param orderId ID of the order that needs to be deleted */ public void deleteOrder(String orderId) throws ApiException { + deleteOrderWithHttpInfo(orderId); + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted + * @return ApiResponse + */ + public ApiResponse deleteOrderWithHttpInfo(String orderId) throws ApiException { Call call = deleteOrderCall(orderId, null, null); - apiClient.execute(call); + return apiClient.execute(call); } /** @@ -380,7 +423,7 @@ public class StoreApi { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - if(callback != null) { + if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java index 57aebd4a4d1..ccb59552554 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java @@ -3,6 +3,7 @@ package io.swagger.client.api; import io.swagger.client.ApiCallback; import io.swagger.client.ApiClient; import io.swagger.client.ApiException; +import io.swagger.client.ApiResponse; import io.swagger.client.Configuration; import io.swagger.client.Pair; import io.swagger.client.ProgressRequestBody; @@ -90,8 +91,18 @@ public class UserApi { * @param body Created user object */ public void createUser(User body) throws ApiException { + createUserWithHttpInfo(body); + } + + /** + * Create user + * This can only be done by the logged in user. + * @param body Created user object + * @return ApiResponse + */ + public ApiResponse createUserWithHttpInfo(User body) throws ApiException { Call call = createUserCall(body, null, null); - apiClient.execute(call); + return apiClient.execute(call); } /** @@ -106,7 +117,7 @@ public class UserApi { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - if(callback != null) { + if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { @@ -175,8 +186,18 @@ public class UserApi { * @param body List of user object */ public void createUsersWithArrayInput(List body) throws ApiException { + createUsersWithArrayInputWithHttpInfo(body); + } + + /** + * Creates list of users with given input array + * + * @param body List of user object + * @return ApiResponse + */ + public ApiResponse createUsersWithArrayInputWithHttpInfo(List body) throws ApiException { Call call = createUsersWithArrayInputCall(body, null, null); - apiClient.execute(call); + return apiClient.execute(call); } /** @@ -191,7 +212,7 @@ public class UserApi { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - if(callback != null) { + if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { @@ -260,8 +281,18 @@ public class UserApi { * @param body List of user object */ public void createUsersWithListInput(List body) throws ApiException { + createUsersWithListInputWithHttpInfo(body); + } + + /** + * Creates list of users with given input array + * + * @param body List of user object + * @return ApiResponse + */ + public ApiResponse createUsersWithListInputWithHttpInfo(List body) throws ApiException { Call call = createUsersWithListInputCall(body, null, null); - apiClient.execute(call); + return apiClient.execute(call); } /** @@ -276,7 +307,7 @@ public class UserApi { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - if(callback != null) { + if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { @@ -298,7 +329,7 @@ public class UserApi { } /* Build call for loginUser */ - private Call loginUserCall(String username,String password, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + private Call loginUserCall(String username, String password, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object postBody = null; @@ -351,7 +382,19 @@ public class UserApi { * @return String */ public String loginUser(String username, String password) throws ApiException { - Call call = loginUserCall(username,password, null, null); + ApiResponse resp = loginUserWithHttpInfo(username, password); + return resp.getData(); + } + + /** + * Logs user into the system + * + * @param username The user name for login + * @param password The password for login in clear text + * @return ApiResponse + */ + public ApiResponse loginUserWithHttpInfo(String username, String password) throws ApiException { + Call call = loginUserCall(username, password, null, null); Type returnType = new TypeToken(){}.getType(); return apiClient.execute(call, returnType); } @@ -369,7 +412,7 @@ public class UserApi { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - if(callback != null) { + if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { @@ -385,14 +428,14 @@ public class UserApi { }; } - Call call = loginUserCall(username,password, progressListener, progressRequestListener); + Call call = loginUserCall(username, password, progressListener, progressRequestListener); Type returnType = new TypeToken(){}.getType(); apiClient.executeAsync(call, returnType, callback); return call; } /* Build call for logoutUser */ - private Call logoutUserCall( final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + private Call logoutUserCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object postBody = null; @@ -438,8 +481,17 @@ public class UserApi { * */ public void logoutUser() throws ApiException { - Call call = logoutUserCall( null, null); - apiClient.execute(call); + logoutUserWithHttpInfo(); + } + + /** + * Logs out current logged in user session + * + * @return ApiResponse + */ + public ApiResponse logoutUserWithHttpInfo() throws ApiException { + Call call = logoutUserCall(null, null); + return apiClient.execute(call); } /** @@ -453,7 +505,7 @@ public class UserApi { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - if(callback != null) { + if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { @@ -469,7 +521,7 @@ public class UserApi { }; } - Call call = logoutUserCall( progressListener, progressRequestListener); + Call call = logoutUserCall(progressListener, progressRequestListener); apiClient.executeAsync(call, callback); return call; } @@ -529,6 +581,17 @@ public class UserApi { * @return User */ public User getUserByName(String username) throws ApiException { + ApiResponse resp = getUserByNameWithHttpInfo(username); + return resp.getData(); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. + * @return ApiResponse + */ + public ApiResponse getUserByNameWithHttpInfo(String username) throws ApiException { Call call = getUserByNameCall(username, null, null); Type returnType = new TypeToken(){}.getType(); return apiClient.execute(call, returnType); @@ -546,7 +609,7 @@ public class UserApi { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - if(callback != null) { + if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { @@ -569,7 +632,7 @@ public class UserApi { } /* Build call for updateUser */ - private Call updateUserCall(String username,User body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + private Call updateUserCall(String username, User body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object postBody = body; // verify the required parameter 'username' is set @@ -623,8 +686,19 @@ public class UserApi { * @param body Updated user object */ public void updateUser(String username, User body) throws ApiException { - Call call = updateUserCall(username,body, null, null); - apiClient.execute(call); + updateUserWithHttpInfo(username, body); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted + * @param body Updated user object + * @return ApiResponse + */ + public ApiResponse updateUserWithHttpInfo(String username, User body) throws ApiException { + Call call = updateUserCall(username, body, null, null); + return apiClient.execute(call); } /** @@ -640,7 +714,7 @@ public class UserApi { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - if(callback != null) { + if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { @@ -656,7 +730,7 @@ public class UserApi { }; } - Call call = updateUserCall(username,body, progressListener, progressRequestListener); + Call call = updateUserCall(username, body, progressListener, progressRequestListener); apiClient.executeAsync(call, callback); return call; } @@ -715,8 +789,18 @@ public class UserApi { * @param username The name that needs to be deleted */ public void deleteUser(String username) throws ApiException { + deleteUserWithHttpInfo(username); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted + * @return ApiResponse + */ + public ApiResponse deleteUserWithHttpInfo(String username) throws ApiException { Call call = deleteUserCall(username, null, null); - apiClient.execute(call); + return apiClient.execute(call); } /** @@ -731,7 +815,7 @@ public class UserApi { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - if(callback != null) { + if (callback != null) { progressListener = new ProgressResponseBody.ProgressListener() { @Override public void update(long bytesRead, long contentLength, boolean done) { diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/PetApiTest.java index b6d8286d7ef..56cc8073984 100644 --- a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/PetApiTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/PetApiTest.java @@ -1,10 +1,6 @@ package io.swagger.petstore.test; -import io.swagger.client.ApiClient; -import io.swagger.client.ApiException; -import io.swagger.client.Configuration; - -import io.swagger.client.ApiCallback; +import io.swagger.client.*; import io.swagger.client.api.*; import io.swagger.client.auth.*; import io.swagger.client.model.*; @@ -71,6 +67,21 @@ public class PetApiTest { assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); } + @Test + public void testCreateAndGetPetWithHttpInfo() throws Exception { + Pet pet = createRandomPet(); + api.addPetWithHttpInfo(pet); + + ApiResponse resp = api.getPetByIdWithHttpInfo(pet.getId()); + assertEquals(200, resp.getStatusCode()); + assertEquals("application/json", resp.getHeaders().get("Content-Type").get(0)); + Pet fetched = resp.getData(); + assertNotNull(fetched); + assertEquals(pet.getId(), fetched.getId()); + assertNotNull(fetched.getCategory()); + assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); + } + @Test public void testCreateAndGetPetAsync() throws Exception { Pet pet = createRandomPet(); From 80ed75eef08e8a12d9db23f9543fc3fcdeac7558 Mon Sep 17 00:00:00 2001 From: xhh Date: Mon, 7 Dec 2015 12:23:50 +0800 Subject: [PATCH 09/17] Add more javadoc to Java okhttp-gson client --- .../libraries/okhttp-gson/ApiClient.mustache | 14 ++++++++++- .../okhttp-gson/ApiResponse.mustache | 14 +++++++++++ .../Java/libraries/okhttp-gson/api.mustache | 3 +++ .../java/io/swagger/client/ApiClient.java | 14 ++++++++++- .../java/io/swagger/client/ApiException.java | 2 +- .../java/io/swagger/client/ApiResponse.java | 14 +++++++++++ .../java/io/swagger/client/Configuration.java | 2 +- .../src/main/java/io/swagger/client/Pair.java | 2 +- .../java/io/swagger/client/StringUtil.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 24 +++++++++++++++++++ .../java/io/swagger/client/api/StoreApi.java | 12 ++++++++++ .../java/io/swagger/client/api/UserApi.java | 24 +++++++++++++++++++ .../io/swagger/client/auth/ApiKeyAuth.java | 2 +- .../swagger/client/auth/Authentication.java | 2 +- .../java/io/swagger/client/auth/OAuth.java | 2 +- .../java/io/swagger/client/model/Pet.java | 2 +- 16 files changed, 125 insertions(+), 10 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache index 7b21d760f56..e97e4c7f97d 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache @@ -597,6 +597,8 @@ public class ApiClient { * @param response HTTP response * @param returnType The type of the Java object * @return The deserialized Java object + * @throws ApiException If fail to deserialize response body, i.e. cannot read response body + * or the Content-Type of the response is not supported. */ public T deserialize(Response response, Type returnType) throws ApiException { if (response == null || returnType == null) @@ -645,6 +647,7 @@ public class ApiClient { * @param obj The Java object * @param contentType The request Content-Type * @return The serialized string + * @throws ApiException If fail to serialize the given object */ public String serialize(Object obj, String contentType) throws ApiException { if (contentType.startsWith("application/json")) { @@ -659,6 +662,7 @@ public class ApiClient { /** * Download file from the given response. + * @throws ApiException If fail to read file content from response and write to disk */ public File downloadFileFromResponse(Response response) throws ApiException { try { @@ -722,6 +726,7 @@ public class ApiClient { * @return ApiResponse object containing response status, headers and * data, which is a Java object deserialized from response body and would be null * when returnType is null. + * @throws ApiException If fail to execute the call */ public ApiResponse execute(Call call, Type returnType) throws ApiException { try { @@ -736,7 +741,7 @@ public class ApiClient { /** * #see executeAsync(Call, Type, ApiCallback) */ - public void executeAsync(Call call, ApiCallback callback) throws ApiException { + public void executeAsync(Call call, ApiCallback callback) { executeAsync(call, null, callback); } @@ -767,6 +772,12 @@ public class ApiClient { }); } + /** + * Handle the given response, return the deserialized object when the response is successful. + * + * @throws ApiException If the response has a unsuccessful status code or + * fail to deserialize the response body + */ public T handleResponse(Response response, Type returnType) throws ApiException { if (response.isSuccessful()) { if (returnType == null || response.code() == 204) { @@ -800,6 +811,7 @@ public class ApiClient { * @param formParams The form parameters * @param authNames The authentications to apply * @return The HTTP call + * @throws ApiException If fail to serialize the request body object */ public Call buildCall(String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { updateParamsForAuth(authNames, queryParams, headerParams); diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiResponse.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiResponse.mustache index 945de39da70..452f4e1e982 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiResponse.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiResponse.mustache @@ -3,15 +3,29 @@ package {{invokerPackage}}; import java.util.List; import java.util.Map; +/** + * API response returned by API call. + * + * @param T The type of data that is deserialized from response body + */ public class ApiResponse { final private int statusCode; final private Map> headers; final private T data; + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + */ public ApiResponse(int statusCode, Map> headers) { this(statusCode, headers, null); } + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + * @param data The object deserialized from response bod + */ public ApiResponse(int statusCode, Map> headers, T data) { this.statusCode = statusCode; this.headers = headers; diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache index da145d08df2..e760f4a370e 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache @@ -105,6 +105,7 @@ public class {{classname}} { * {{notes}}{{#allParams}} * @param {{paramName}} {{description}}{{/allParams}}{{#returnType}} * @return {{{returnType}}}{{/returnType}} + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException { {{#returnType}}ApiResponse<{{{returnType}}}> {{localVariablePrefix}}resp = {{/returnType}}{{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} @@ -116,6 +117,7 @@ public class {{classname}} { * {{notes}}{{#allParams}} * @param {{paramName}} {{description}}{{/allParams}} * @return ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException { Call {{localVariablePrefix}}call = {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}null, null); @@ -129,6 +131,7 @@ public class {{classname}} { * @param {{paramName}} {{description}}{{/allParams}} * @param callback The callback to be executed when the API call finishes * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public Call {{operationId}}Async({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ApiCallback<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{localVariablePrefix}}callback) throws ApiException { diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java index 8a75219bb53..d4ee79cb3ad 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java @@ -596,6 +596,8 @@ public class ApiClient { * @param response HTTP response * @param returnType The type of the Java object * @return The deserialized Java object + * @throws ApiException If fail to deserialize response body, i.e. cannot read response body + * or the Content-Type of the response is not supported. */ public T deserialize(Response response, Type returnType) throws ApiException { if (response == null || returnType == null) @@ -644,6 +646,7 @@ public class ApiClient { * @param obj The Java object * @param contentType The request Content-Type * @return The serialized string + * @throws ApiException If fail to serialize the given object */ public String serialize(Object obj, String contentType) throws ApiException { if (contentType.startsWith("application/json")) { @@ -658,6 +661,7 @@ public class ApiClient { /** * Download file from the given response. + * @throws ApiException If fail to read file content from response and write to disk */ public File downloadFileFromResponse(Response response) throws ApiException { try { @@ -721,6 +725,7 @@ public class ApiClient { * @return ApiResponse object containing response status, headers and * data, which is a Java object deserialized from response body and would be null * when returnType is null. + * @throws ApiException If fail to execute the call */ public ApiResponse execute(Call call, Type returnType) throws ApiException { try { @@ -735,7 +740,7 @@ public class ApiClient { /** * #see executeAsync(Call, Type, ApiCallback) */ - public void executeAsync(Call call, ApiCallback callback) throws ApiException { + public void executeAsync(Call call, ApiCallback callback) { executeAsync(call, null, callback); } @@ -766,6 +771,12 @@ public class ApiClient { }); } + /** + * Handle the given response, return the deserialized object when the response is successful. + * + * @throws ApiException If the response has a unsuccessful status code or + * fail to deserialize the response body + */ public T handleResponse(Response response, Type returnType) throws ApiException { if (response.isSuccessful()) { if (returnType == null || response.code() == 204) { @@ -799,6 +810,7 @@ public class ApiClient { * @param formParams The form parameters * @param authNames The authentications to apply * @return The HTTP call + * @throws ApiException If fail to serialize the request body object */ public Call buildCall(String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { updateParamsForAuth(authNames, queryParams, headerParams); diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java index 46b52990f44..bf096d22a5c 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiException.java @@ -3,7 +3,7 @@ package io.swagger.client; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:08.052+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T12:21:33.403+08:00") public class ApiException extends Exception { private int code = 0; private Map> responseHeaders = null; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiResponse.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiResponse.java index fbe22e077b8..0a33f09e64e 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiResponse.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiResponse.java @@ -3,15 +3,29 @@ package io.swagger.client; import java.util.List; import java.util.Map; +/** + * API response returned by API call. + * + * @param T The type of data that is deserialized from response body + */ public class ApiResponse { final private int statusCode; final private Map> headers; final private T data; + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + */ public ApiResponse(int statusCode, Map> headers) { this(statusCode, headers, null); } + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + * @param data The object deserialized from response bod + */ public ApiResponse(int statusCode, Map> headers, T data) { this.statusCode = statusCode; this.headers = headers; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java index b99c939af83..e996b89ef77 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Configuration.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:08.052+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T12:21:33.403+08:00") public class Configuration { private static ApiClient defaultApiClient = new ApiClient(); diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java index 98f5f92e0a4..ef80752c495 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/Pair.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:08.052+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T12:21:33.403+08:00") public class Pair { private String name = ""; private String value = ""; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java index 702b8cf350c..3a105a258e4 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:08.052+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T12:21:33.403+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java index e880e3f9fbf..460cd0f4c4d 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java @@ -89,6 +89,7 @@ public class PetApi { * Update an existing pet * * @param body Pet object that needs to be added to the store + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void updatePet(Pet body) throws ApiException { updatePetWithHttpInfo(body); @@ -99,6 +100,7 @@ public class PetApi { * * @param body Pet object that needs to be added to the store * @return ApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse updatePetWithHttpInfo(Pet body) throws ApiException { Call call = updatePetCall(body, null, null); @@ -111,6 +113,7 @@ public class PetApi { * @param body Pet object that needs to be added to the store * @param callback The callback to be executed when the API call finishes * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public Call updatePetAsync(Pet body, final ApiCallback callback) throws ApiException { @@ -184,6 +187,7 @@ public class PetApi { * Add a new pet to the store * * @param body Pet object that needs to be added to the store + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void addPet(Pet body) throws ApiException { addPetWithHttpInfo(body); @@ -194,6 +198,7 @@ public class PetApi { * * @param body Pet object that needs to be added to the store * @return ApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse addPetWithHttpInfo(Pet body) throws ApiException { Call call = addPetCall(body, null, null); @@ -206,6 +211,7 @@ public class PetApi { * @param body Pet object that needs to be added to the store * @param callback The callback to be executed when the API call finishes * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public Call addPetAsync(Pet body, final ApiCallback callback) throws ApiException { @@ -282,6 +288,7 @@ public class PetApi { * Multiple status values can be provided with comma seperated strings * @param status Status values that need to be considered for filter * @return List + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public List findPetsByStatus(List status) throws ApiException { ApiResponse> resp = findPetsByStatusWithHttpInfo(status); @@ -293,6 +300,7 @@ public class PetApi { * Multiple status values can be provided with comma seperated strings * @param status Status values that need to be considered for filter * @return ApiResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse> findPetsByStatusWithHttpInfo(List status) throws ApiException { Call call = findPetsByStatusCall(status, null, null); @@ -306,6 +314,7 @@ public class PetApi { * @param status Status values that need to be considered for filter * @param callback The callback to be executed when the API call finishes * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public Call findPetsByStatusAsync(List status, final ApiCallback> callback) throws ApiException { @@ -383,6 +392,7 @@ public class PetApi { * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by * @return List + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public List findPetsByTags(List tags) throws ApiException { ApiResponse> resp = findPetsByTagsWithHttpInfo(tags); @@ -394,6 +404,7 @@ public class PetApi { * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by * @return ApiResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse> findPetsByTagsWithHttpInfo(List tags) throws ApiException { Call call = findPetsByTagsCall(tags, null, null); @@ -407,6 +418,7 @@ public class PetApi { * @param tags Tags to filter by * @param callback The callback to be executed when the API call finishes * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public Call findPetsByTagsAsync(List tags, final ApiCallback> callback) throws ApiException { @@ -488,6 +500,7 @@ public class PetApi { * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param petId ID of pet that needs to be fetched * @return Pet + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public Pet getPetById(Long petId) throws ApiException { ApiResponse resp = getPetByIdWithHttpInfo(petId); @@ -499,6 +512,7 @@ public class PetApi { * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param petId ID of pet that needs to be fetched * @return ApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse getPetByIdWithHttpInfo(Long petId) throws ApiException { Call call = getPetByIdCall(petId, null, null); @@ -512,6 +526,7 @@ public class PetApi { * @param petId ID of pet that needs to be fetched * @param callback The callback to be executed when the API call finishes * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public Call getPetByIdAsync(Long petId, final ApiCallback callback) throws ApiException { @@ -598,6 +613,7 @@ public class PetApi { * @param petId ID of pet that needs to be updated * @param name Updated name of the pet * @param status Updated status of the pet + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void updatePetWithForm(String petId, String name, String status) throws ApiException { updatePetWithFormWithHttpInfo(petId, name, status); @@ -610,6 +626,7 @@ public class PetApi { * @param name Updated name of the pet * @param status Updated status of the pet * @return ApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse updatePetWithFormWithHttpInfo(String petId, String name, String status) throws ApiException { Call call = updatePetWithFormCall(petId, name, status, null, null); @@ -624,6 +641,7 @@ public class PetApi { * @param status Updated status of the pet * @param callback The callback to be executed when the API call finishes * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public Call updatePetWithFormAsync(String petId, String name, String status, final ApiCallback callback) throws ApiException { @@ -706,6 +724,7 @@ public class PetApi { * * @param petId Pet id to delete * @param apiKey + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void deletePet(Long petId, String apiKey) throws ApiException { deletePetWithHttpInfo(petId, apiKey); @@ -717,6 +736,7 @@ public class PetApi { * @param petId Pet id to delete * @param apiKey * @return ApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse deletePetWithHttpInfo(Long petId, String apiKey) throws ApiException { Call call = deletePetCall(petId, apiKey, null, null); @@ -730,6 +750,7 @@ public class PetApi { * @param apiKey * @param callback The callback to be executed when the API call finishes * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public Call deletePetAsync(Long petId, String apiKey, final ApiCallback callback) throws ApiException { @@ -815,6 +836,7 @@ public class PetApi { * @param petId ID of pet to update * @param additionalMetadata Additional data to pass to server * @param file file to upload + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void uploadFile(Long petId, String additionalMetadata, File file) throws ApiException { uploadFileWithHttpInfo(petId, additionalMetadata, file); @@ -827,6 +849,7 @@ public class PetApi { * @param additionalMetadata Additional data to pass to server * @param file file to upload * @return ApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse uploadFileWithHttpInfo(Long petId, String additionalMetadata, File file) throws ApiException { Call call = uploadFileCall(petId, additionalMetadata, file, null, null); @@ -841,6 +864,7 @@ public class PetApi { * @param file file to upload * @param callback The callback to be executed when the API call finishes * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public Call uploadFileAsync(Long petId, String additionalMetadata, File file, final ApiCallback callback) throws ApiException { diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java index 3e06890a81c..5e6c7c48c6b 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java @@ -89,6 +89,7 @@ public class StoreApi { * Returns pet inventories by status * Returns a map of status codes to quantities * @return Map + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public Map getInventory() throws ApiException { ApiResponse> resp = getInventoryWithHttpInfo(); @@ -99,6 +100,7 @@ public class StoreApi { * Returns pet inventories by status * Returns a map of status codes to quantities * @return ApiResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse> getInventoryWithHttpInfo() throws ApiException { Call call = getInventoryCall(null, null); @@ -111,6 +113,7 @@ public class StoreApi { * Returns a map of status codes to quantities * @param callback The callback to be executed when the API call finishes * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public Call getInventoryAsync(final ApiCallback> callback) throws ApiException { @@ -186,6 +189,7 @@ public class StoreApi { * * @param body order placed for purchasing the pet * @return Order + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public Order placeOrder(Order body) throws ApiException { ApiResponse resp = placeOrderWithHttpInfo(body); @@ -197,6 +201,7 @@ public class StoreApi { * * @param body order placed for purchasing the pet * @return ApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse placeOrderWithHttpInfo(Order body) throws ApiException { Call call = placeOrderCall(body, null, null); @@ -210,6 +215,7 @@ public class StoreApi { * @param body order placed for purchasing the pet * @param callback The callback to be executed when the API call finishes * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public Call placeOrderAsync(Order body, final ApiCallback callback) throws ApiException { @@ -291,6 +297,7 @@ public class StoreApi { * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param orderId ID of pet that needs to be fetched * @return Order + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public Order getOrderById(String orderId) throws ApiException { ApiResponse resp = getOrderByIdWithHttpInfo(orderId); @@ -302,6 +309,7 @@ public class StoreApi { * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param orderId ID of pet that needs to be fetched * @return ApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse getOrderByIdWithHttpInfo(String orderId) throws ApiException { Call call = getOrderByIdCall(orderId, null, null); @@ -315,6 +323,7 @@ public class StoreApi { * @param orderId ID of pet that needs to be fetched * @param callback The callback to be executed when the API call finishes * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public Call getOrderByIdAsync(String orderId, final ApiCallback callback) throws ApiException { @@ -395,6 +404,7 @@ public class StoreApi { * Delete purchase order by ID * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @param orderId ID of the order that needs to be deleted + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void deleteOrder(String orderId) throws ApiException { deleteOrderWithHttpInfo(orderId); @@ -405,6 +415,7 @@ public class StoreApi { * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @param orderId ID of the order that needs to be deleted * @return ApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse deleteOrderWithHttpInfo(String orderId) throws ApiException { Call call = deleteOrderCall(orderId, null, null); @@ -417,6 +428,7 @@ public class StoreApi { * @param orderId ID of the order that needs to be deleted * @param callback The callback to be executed when the API call finishes * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public Call deleteOrderAsync(String orderId, final ApiCallback callback) throws ApiException { diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java index ccb59552554..ab043bdbe3b 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/UserApi.java @@ -89,6 +89,7 @@ public class UserApi { * Create user * This can only be done by the logged in user. * @param body Created user object + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void createUser(User body) throws ApiException { createUserWithHttpInfo(body); @@ -99,6 +100,7 @@ public class UserApi { * This can only be done by the logged in user. * @param body Created user object * @return ApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse createUserWithHttpInfo(User body) throws ApiException { Call call = createUserCall(body, null, null); @@ -111,6 +113,7 @@ public class UserApi { * @param body Created user object * @param callback The callback to be executed when the API call finishes * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public Call createUserAsync(User body, final ApiCallback callback) throws ApiException { @@ -184,6 +187,7 @@ public class UserApi { * Creates list of users with given input array * * @param body List of user object + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void createUsersWithArrayInput(List body) throws ApiException { createUsersWithArrayInputWithHttpInfo(body); @@ -194,6 +198,7 @@ public class UserApi { * * @param body List of user object * @return ApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse createUsersWithArrayInputWithHttpInfo(List body) throws ApiException { Call call = createUsersWithArrayInputCall(body, null, null); @@ -206,6 +211,7 @@ public class UserApi { * @param body List of user object * @param callback The callback to be executed when the API call finishes * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public Call createUsersWithArrayInputAsync(List body, final ApiCallback callback) throws ApiException { @@ -279,6 +285,7 @@ public class UserApi { * Creates list of users with given input array * * @param body List of user object + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void createUsersWithListInput(List body) throws ApiException { createUsersWithListInputWithHttpInfo(body); @@ -289,6 +296,7 @@ public class UserApi { * * @param body List of user object * @return ApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse createUsersWithListInputWithHttpInfo(List body) throws ApiException { Call call = createUsersWithListInputCall(body, null, null); @@ -301,6 +309,7 @@ public class UserApi { * @param body List of user object * @param callback The callback to be executed when the API call finishes * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public Call createUsersWithListInputAsync(List body, final ApiCallback callback) throws ApiException { @@ -380,6 +389,7 @@ public class UserApi { * @param username The user name for login * @param password The password for login in clear text * @return String + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public String loginUser(String username, String password) throws ApiException { ApiResponse resp = loginUserWithHttpInfo(username, password); @@ -392,6 +402,7 @@ public class UserApi { * @param username The user name for login * @param password The password for login in clear text * @return ApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse loginUserWithHttpInfo(String username, String password) throws ApiException { Call call = loginUserCall(username, password, null, null); @@ -406,6 +417,7 @@ public class UserApi { * @param password The password for login in clear text * @param callback The callback to be executed when the API call finishes * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public Call loginUserAsync(String username, String password, final ApiCallback callback) throws ApiException { @@ -479,6 +491,7 @@ public class UserApi { /** * Logs out current logged in user session * + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void logoutUser() throws ApiException { logoutUserWithHttpInfo(); @@ -488,6 +501,7 @@ public class UserApi { * Logs out current logged in user session * * @return ApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse logoutUserWithHttpInfo() throws ApiException { Call call = logoutUserCall(null, null); @@ -499,6 +513,7 @@ public class UserApi { * * @param callback The callback to be executed when the API call finishes * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public Call logoutUserAsync(final ApiCallback callback) throws ApiException { @@ -579,6 +594,7 @@ public class UserApi { * * @param username The name that needs to be fetched. Use user1 for testing. * @return User + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public User getUserByName(String username) throws ApiException { ApiResponse resp = getUserByNameWithHttpInfo(username); @@ -590,6 +606,7 @@ public class UserApi { * * @param username The name that needs to be fetched. Use user1 for testing. * @return ApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse getUserByNameWithHttpInfo(String username) throws ApiException { Call call = getUserByNameCall(username, null, null); @@ -603,6 +620,7 @@ public class UserApi { * @param username The name that needs to be fetched. Use user1 for testing. * @param callback The callback to be executed when the API call finishes * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public Call getUserByNameAsync(String username, final ApiCallback callback) throws ApiException { @@ -684,6 +702,7 @@ public class UserApi { * This can only be done by the logged in user. * @param username name that need to be deleted * @param body Updated user object + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void updateUser(String username, User body) throws ApiException { updateUserWithHttpInfo(username, body); @@ -695,6 +714,7 @@ public class UserApi { * @param username name that need to be deleted * @param body Updated user object * @return ApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse updateUserWithHttpInfo(String username, User body) throws ApiException { Call call = updateUserCall(username, body, null, null); @@ -708,6 +728,7 @@ public class UserApi { * @param body Updated user object * @param callback The callback to be executed when the API call finishes * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public Call updateUserAsync(String username, User body, final ApiCallback callback) throws ApiException { @@ -787,6 +808,7 @@ public class UserApi { * Delete user * This can only be done by the logged in user. * @param username The name that needs to be deleted + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public void deleteUser(String username) throws ApiException { deleteUserWithHttpInfo(username); @@ -797,6 +819,7 @@ public class UserApi { * This can only be done by the logged in user. * @param username The name that needs to be deleted * @return ApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ public ApiResponse deleteUserWithHttpInfo(String username) throws ApiException { Call call = deleteUserCall(username, null, null); @@ -809,6 +832,7 @@ public class UserApi { * @param username The name that needs to be deleted * @param callback The callback to be executed when the API call finishes * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public Call deleteUserAsync(String username, final ApiCallback callback) throws ApiException { diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java index 2110aff20d8..8439d297d45 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:08.052+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T12:21:33.403+08:00") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/Authentication.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/Authentication.java index f00217c451e..6817892cce9 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/Authentication.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/Authentication.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:08.052+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T12:21:33.403+08:00") public interface Authentication { /** Apply authentication settings to header and query params. */ void applyToParams(List queryParams, Map headerParams); diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java index b750aaa2360..d0b457bacd8 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/OAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:08.052+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T12:21:33.403+08:00") public class OAuth implements Authentication { private String accessToken; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Pet.java index bc3b80370b0..7e771866b39 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Pet.java @@ -2,8 +2,8 @@ package io.swagger.client.model; import io.swagger.client.StringUtil; import io.swagger.client.model.Category; -import io.swagger.client.model.Tag; import java.util.*; +import io.swagger.client.model.Tag; import com.google.gson.annotations.SerializedName; From 66112d9eb5bc228cc53bce0958570d6a64ad70cc Mon Sep 17 00:00:00 2001 From: xhh Date: Mon, 7 Dec 2015 15:48:59 +0800 Subject: [PATCH 10/17] Added with-http-info API methods to Ruby client to allow accessing response status code and headers, and removed the methods of recording last response info from ApiClient. --- .../src/main/resources/ruby/api.mustache | 30 ++-- .../main/resources/ruby/api_client.mustache | 13 +- .../petstore/ruby/lib/petstore/api/pet_api.rb | 133 ++++++++++++++---- .../ruby/lib/petstore/api/store_api.rb | 63 +++++++-- .../ruby/lib/petstore/api/user_api.rb | 129 +++++++++++++---- .../petstore/ruby/lib/petstore/api_client.rb | 13 +- samples/client/petstore/ruby/spec/pet_spec.rb | 11 ++ 7 files changed, 302 insertions(+), 90 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/ruby/api.mustache b/modules/swagger-codegen/src/main/resources/ruby/api.mustache index b8e2e0da4c8..999aa4a9776 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/api.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/api.mustache @@ -17,6 +17,17 @@ module {{moduleName}} {{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}} {{/required}}{{/allParams}} # @return [{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}] def {{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {}) + {{#returnType}}status_code, headers, data = {{/returnType}}{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts) + {{#returnType}}return data{{/returnType}}{{^returnType}}return nil{{/returnType}} + end + + # {{summary}} + # {{notes}} +{{#allParams}}{{#required}} # @param {{paramName}} {{description}} +{{/required}}{{/allParams}} # @param [Hash] opts the optional parameters +{{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}} +{{/required}}{{/allParams}} # @return [Array] response status code, response headers and {{#returnType}}{{{returnType}}} data{{/returnType}}{{^returnType}}nil{{/returnType}} + def {{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: {{classname}}#{{operationId}} ..." end @@ -63,26 +74,17 @@ module {{moduleName}} {{/bodyParam}} auth_names = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}] - {{#returnType}}result = @api_client.call_api(:{{httpMethod}}, path, + status_code, headers, data = @api_client.call_api(:{{httpMethod}}, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, - :auth_names => auth_names, - :return_type => '{{{returnType}}}') + :auth_names => auth_names{{#returnType}}, + :return_type => '{{{returnType}}}'{{/returnType}}) if Configuration.debugging - Configuration.logger.debug "API called: {{classname}}#{{operationId}}. Result: #{result.inspect}" + Configuration.logger.debug "API called: {{classname}}#{{operationId}}\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" end - return result{{/returnType}}{{^returnType}}@api_client.call_api(:{{httpMethod}}, path, - :header_params => header_params, - :query_params => query_params, - :form_params => form_params, - :body => post_body, - :auth_names => auth_names) - if Configuration.debugging - Configuration.logger.debug "API called: {{classname}}#{{operationId}}" - end - return nil{{/returnType}} + return status_code, headers, data end {{/operation}} end diff --git a/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache b/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache index 4ef665bddf2..b5b67aa21eb 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache @@ -15,9 +15,6 @@ module {{moduleName}} # @return [Hash] attr_accessor :default_headers - # Stores the HTTP response from the last API call using this API client. - attr_accessor :last_response - def initialize(host = nil) @host = host || Configuration.base_url @format = 'json' @@ -28,13 +25,12 @@ module {{moduleName}} } end + # Call an API with given options and an array of 3 elements: + # response status code, response headers and the data deserialized from response body (could be nil). def call_api(http_method, path, opts = {}) request = build_request(http_method, path, opts) response = request.run - # record as last response - @last_response = response - if Configuration.debugging Configuration.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n" end @@ -47,10 +43,11 @@ module {{moduleName}} end if opts[:return_type] - deserialize(response, opts[:return_type]) + data = deserialize(response, opts[:return_type]) else - nil + data = nil end + return response.code, response.headers, data end def build_request(http_method, path, opts = {}) 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 887f86dd45c..9e3dcd1dea3 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb @@ -14,6 +14,16 @@ module Petstore # @option opts [Pet] :body Pet object that needs to be added to the store # @return [nil] def update_pet(opts = {}) + update_pet_with_http_info(opts) + return nil + end + + # Update an existing pet + # + # @param [Hash] opts the optional parameters + # @option opts [Pet] :body Pet object that needs to be added to the store + # @return [Array] response status code, response headers and nil + def update_pet_with_http_info(opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: PetApi#update_pet ..." end @@ -43,16 +53,16 @@ module Petstore auth_names = ['petstore_auth'] - @api_client.call_api(:PUT, path, + status_code, headers, data = @api_client.call_api(:PUT, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if Configuration.debugging - Configuration.logger.debug "API called: PetApi#update_pet" + Configuration.logger.debug "API called: PetApi#update_pet\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" end - return nil + return status_code, headers, data end # Add a new pet to the store @@ -61,6 +71,16 @@ module Petstore # @option opts [Pet] :body Pet object that needs to be added to the store # @return [nil] def add_pet(opts = {}) + add_pet_with_http_info(opts) + return nil + end + + # Add a new pet to the store + # + # @param [Hash] opts the optional parameters + # @option opts [Pet] :body Pet object that needs to be added to the store + # @return [Array] response status code, response headers and nil + def add_pet_with_http_info(opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: PetApi#add_pet ..." end @@ -90,16 +110,16 @@ module Petstore auth_names = ['petstore_auth'] - @api_client.call_api(:POST, path, + status_code, headers, data = @api_client.call_api(:POST, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if Configuration.debugging - Configuration.logger.debug "API called: PetApi#add_pet" + Configuration.logger.debug "API called: PetApi#add_pet\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" end - return nil + return status_code, headers, data end # Finds Pets by status @@ -108,6 +128,16 @@ module Petstore # @option opts [Array] :status Status values that need to be considered for filter # @return [Array] def find_pets_by_status(opts = {}) + status_code, headers, data = find_pets_by_status_with_http_info(opts) + return data + end + + # Finds Pets by status + # Multiple status values can be provided with comma seperated strings + # @param [Hash] opts the optional parameters + # @option opts [Array] :status Status values that need to be considered for filter + # @return [Array>] response status code, response headers and Array data + def find_pets_by_status_with_http_info(opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: PetApi#find_pets_by_status ..." end @@ -138,7 +168,7 @@ module Petstore auth_names = ['petstore_auth'] - result = @api_client.call_api(:GET, path, + status_code, headers, data = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -146,9 +176,9 @@ module Petstore :auth_names => auth_names, :return_type => 'Array') if Configuration.debugging - Configuration.logger.debug "API called: PetApi#find_pets_by_status. Result: #{result.inspect}" + Configuration.logger.debug "API called: PetApi#find_pets_by_status\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" end - return result + return status_code, headers, data end # Finds Pets by tags @@ -157,6 +187,16 @@ module Petstore # @option opts [Array] :tags Tags to filter by # @return [Array] def find_pets_by_tags(opts = {}) + status_code, headers, data = find_pets_by_tags_with_http_info(opts) + return data + end + + # Finds Pets by tags + # Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + # @param [Hash] opts the optional parameters + # @option opts [Array] :tags Tags to filter by + # @return [Array>] response status code, response headers and Array data + def find_pets_by_tags_with_http_info(opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: PetApi#find_pets_by_tags ..." end @@ -187,7 +227,7 @@ module Petstore auth_names = ['petstore_auth'] - result = @api_client.call_api(:GET, path, + status_code, headers, data = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -195,9 +235,9 @@ module Petstore :auth_names => auth_names, :return_type => 'Array') if Configuration.debugging - Configuration.logger.debug "API called: PetApi#find_pets_by_tags. Result: #{result.inspect}" + Configuration.logger.debug "API called: PetApi#find_pets_by_tags\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" end - return result + return status_code, headers, data end # Find pet by ID @@ -206,6 +246,16 @@ module Petstore # @param [Hash] opts the optional parameters # @return [Pet] def get_pet_by_id(pet_id, opts = {}) + status_code, headers, data = get_pet_by_id_with_http_info(pet_id, opts) + return data + end + + # Find pet by ID + # Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + # @param pet_id ID of pet that needs to be fetched + # @param [Hash] opts the optional parameters + # @return [Array] response status code, response headers and Pet data + def get_pet_by_id_with_http_info(pet_id, opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: PetApi#get_pet_by_id ..." end @@ -238,7 +288,7 @@ module Petstore auth_names = ['api_key'] - result = @api_client.call_api(:GET, path, + status_code, headers, data = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -246,9 +296,9 @@ module Petstore :auth_names => auth_names, :return_type => 'Pet') if Configuration.debugging - Configuration.logger.debug "API called: PetApi#get_pet_by_id. Result: #{result.inspect}" + Configuration.logger.debug "API called: PetApi#get_pet_by_id\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" end - return result + return status_code, headers, data end # Updates a pet in the store with form data @@ -259,6 +309,18 @@ module Petstore # @option opts [String] :status Updated status of the pet # @return [nil] def update_pet_with_form(pet_id, opts = {}) + update_pet_with_form_with_http_info(pet_id, opts) + return nil + end + + # Updates a pet in the store with form data + # + # @param pet_id ID of pet that needs to be updated + # @param [Hash] opts the optional parameters + # @option opts [String] :name Updated name of the pet + # @option opts [String] :status Updated status of the pet + # @return [Array] response status code, response headers and nil + def update_pet_with_form_with_http_info(pet_id, opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: PetApi#update_pet_with_form ..." end @@ -293,16 +355,16 @@ module Petstore auth_names = ['petstore_auth'] - @api_client.call_api(:POST, path, + status_code, headers, data = @api_client.call_api(:POST, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if Configuration.debugging - Configuration.logger.debug "API called: PetApi#update_pet_with_form" + Configuration.logger.debug "API called: PetApi#update_pet_with_form\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" end - return nil + return status_code, headers, data end # Deletes a pet @@ -312,6 +374,17 @@ module Petstore # @option opts [String] :api_key # @return [nil] def delete_pet(pet_id, opts = {}) + delete_pet_with_http_info(pet_id, opts) + return nil + end + + # Deletes a pet + # + # @param pet_id Pet id to delete + # @param [Hash] opts the optional parameters + # @option opts [String] :api_key + # @return [Array] response status code, response headers and nil + def delete_pet_with_http_info(pet_id, opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: PetApi#delete_pet ..." end @@ -345,16 +418,16 @@ module Petstore auth_names = ['petstore_auth'] - @api_client.call_api(:DELETE, path, + status_code, headers, data = @api_client.call_api(:DELETE, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if Configuration.debugging - Configuration.logger.debug "API called: PetApi#delete_pet" + Configuration.logger.debug "API called: PetApi#delete_pet\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" end - return nil + return status_code, headers, data end # uploads an image @@ -365,6 +438,18 @@ module Petstore # @option opts [File] :file file to upload # @return [nil] def upload_file(pet_id, opts = {}) + upload_file_with_http_info(pet_id, opts) + return nil + end + + # uploads an image + # + # @param pet_id ID of pet to update + # @param [Hash] opts the optional parameters + # @option opts [String] :additional_metadata Additional data to pass to server + # @option opts [File] :file file to upload + # @return [Array] response status code, response headers and nil + def upload_file_with_http_info(pet_id, opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: PetApi#upload_file ..." end @@ -399,16 +484,16 @@ module Petstore auth_names = ['petstore_auth'] - @api_client.call_api(:POST, path, + status_code, headers, data = @api_client.call_api(:POST, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if Configuration.debugging - Configuration.logger.debug "API called: PetApi#upload_file" + Configuration.logger.debug "API called: PetApi#upload_file\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" end - return nil + return status_code, headers, data end end end diff --git a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb index 235ff1c4106..d899d893465 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb @@ -13,6 +13,15 @@ module Petstore # @param [Hash] opts the optional parameters # @return [Hash] def get_inventory(opts = {}) + status_code, headers, data = get_inventory_with_http_info(opts) + return data + end + + # Returns pet inventories by status + # Returns a map of status codes to quantities + # @param [Hash] opts the optional parameters + # @return [Array>] response status code, response headers and Hash data + def get_inventory_with_http_info(opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: StoreApi#get_inventory ..." end @@ -42,7 +51,7 @@ module Petstore auth_names = ['api_key'] - result = @api_client.call_api(:GET, path, + status_code, headers, data = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -50,9 +59,9 @@ module Petstore :auth_names => auth_names, :return_type => 'Hash') if Configuration.debugging - Configuration.logger.debug "API called: StoreApi#get_inventory. Result: #{result.inspect}" + Configuration.logger.debug "API called: StoreApi#get_inventory\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" end - return result + return status_code, headers, data end # Place an order for a pet @@ -61,6 +70,16 @@ module Petstore # @option opts [Order] :body order placed for purchasing the pet # @return [Order] def place_order(opts = {}) + status_code, headers, data = place_order_with_http_info(opts) + return data + end + + # Place an order for a pet + # + # @param [Hash] opts the optional parameters + # @option opts [Order] :body order placed for purchasing the pet + # @return [Array] response status code, response headers and Order data + def place_order_with_http_info(opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: StoreApi#place_order ..." end @@ -90,7 +109,7 @@ module Petstore auth_names = [] - result = @api_client.call_api(:POST, path, + status_code, headers, data = @api_client.call_api(:POST, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -98,9 +117,9 @@ module Petstore :auth_names => auth_names, :return_type => 'Order') if Configuration.debugging - Configuration.logger.debug "API called: StoreApi#place_order. Result: #{result.inspect}" + Configuration.logger.debug "API called: StoreApi#place_order\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" end - return result + return status_code, headers, data end # Find purchase order by ID @@ -109,6 +128,16 @@ module Petstore # @param [Hash] opts the optional parameters # @return [Order] def get_order_by_id(order_id, opts = {}) + status_code, headers, data = get_order_by_id_with_http_info(order_id, opts) + return data + end + + # Find purchase order by ID + # For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + # @param order_id ID of pet that needs to be fetched + # @param [Hash] opts the optional parameters + # @return [Array] response status code, response headers and Order data + def get_order_by_id_with_http_info(order_id, opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: StoreApi#get_order_by_id ..." end @@ -141,7 +170,7 @@ module Petstore auth_names = [] - result = @api_client.call_api(:GET, path, + status_code, headers, data = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -149,9 +178,9 @@ module Petstore :auth_names => auth_names, :return_type => 'Order') if Configuration.debugging - Configuration.logger.debug "API called: StoreApi#get_order_by_id. Result: #{result.inspect}" + Configuration.logger.debug "API called: StoreApi#get_order_by_id\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" end - return result + return status_code, headers, data end # Delete purchase order by ID @@ -160,6 +189,16 @@ module Petstore # @param [Hash] opts the optional parameters # @return [nil] def delete_order(order_id, opts = {}) + delete_order_with_http_info(order_id, opts) + return nil + end + + # Delete purchase order by ID + # For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + # @param order_id ID of the order that needs to be deleted + # @param [Hash] opts the optional parameters + # @return [Array] response status code, response headers and nil + def delete_order_with_http_info(order_id, opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: StoreApi#delete_order ..." end @@ -192,16 +231,16 @@ module Petstore auth_names = [] - @api_client.call_api(:DELETE, path, + status_code, headers, data = @api_client.call_api(:DELETE, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if Configuration.debugging - Configuration.logger.debug "API called: StoreApi#delete_order" + Configuration.logger.debug "API called: StoreApi#delete_order\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" end - return nil + return status_code, headers, data end end end 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 7f546330f3a..ed32cc37bad 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb @@ -14,6 +14,16 @@ module Petstore # @option opts [User] :body Created user object # @return [nil] def create_user(opts = {}) + create_user_with_http_info(opts) + return nil + end + + # Create user + # This can only be done by the logged in user. + # @param [Hash] opts the optional parameters + # @option opts [User] :body Created user object + # @return [Array] response status code, response headers and nil + def create_user_with_http_info(opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: UserApi#create_user ..." end @@ -43,16 +53,16 @@ module Petstore auth_names = [] - @api_client.call_api(:POST, path, + status_code, headers, data = @api_client.call_api(:POST, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if Configuration.debugging - Configuration.logger.debug "API called: UserApi#create_user" + Configuration.logger.debug "API called: UserApi#create_user\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" end - return nil + return status_code, headers, data end # Creates list of users with given input array @@ -61,6 +71,16 @@ module Petstore # @option opts [Array] :body List of user object # @return [nil] def create_users_with_array_input(opts = {}) + create_users_with_array_input_with_http_info(opts) + return nil + end + + # Creates list of users with given input array + # + # @param [Hash] opts the optional parameters + # @option opts [Array] :body List of user object + # @return [Array] response status code, response headers and nil + def create_users_with_array_input_with_http_info(opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: UserApi#create_users_with_array_input ..." end @@ -90,16 +110,16 @@ module Petstore auth_names = [] - @api_client.call_api(:POST, path, + status_code, headers, data = @api_client.call_api(:POST, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if Configuration.debugging - Configuration.logger.debug "API called: UserApi#create_users_with_array_input" + Configuration.logger.debug "API called: UserApi#create_users_with_array_input\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" end - return nil + return status_code, headers, data end # Creates list of users with given input array @@ -108,6 +128,16 @@ module Petstore # @option opts [Array] :body List of user object # @return [nil] def create_users_with_list_input(opts = {}) + create_users_with_list_input_with_http_info(opts) + return nil + end + + # Creates list of users with given input array + # + # @param [Hash] opts the optional parameters + # @option opts [Array] :body List of user object + # @return [Array] response status code, response headers and nil + def create_users_with_list_input_with_http_info(opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: UserApi#create_users_with_list_input ..." end @@ -137,16 +167,16 @@ module Petstore auth_names = [] - @api_client.call_api(:POST, path, + status_code, headers, data = @api_client.call_api(:POST, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if Configuration.debugging - Configuration.logger.debug "API called: UserApi#create_users_with_list_input" + Configuration.logger.debug "API called: UserApi#create_users_with_list_input\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" end - return nil + return status_code, headers, data end # Logs user into the system @@ -156,6 +186,17 @@ module Petstore # @option opts [String] :password The password for login in clear text # @return [String] def login_user(opts = {}) + status_code, headers, data = login_user_with_http_info(opts) + return data + end + + # Logs user into the system + # + # @param [Hash] opts the optional parameters + # @option opts [String] :username The user name for login + # @option opts [String] :password The password for login in clear text + # @return [Array] response status code, response headers and String data + def login_user_with_http_info(opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: UserApi#login_user ..." end @@ -187,7 +228,7 @@ module Petstore auth_names = [] - result = @api_client.call_api(:GET, path, + status_code, headers, data = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -195,9 +236,9 @@ module Petstore :auth_names => auth_names, :return_type => 'String') if Configuration.debugging - Configuration.logger.debug "API called: UserApi#login_user. Result: #{result.inspect}" + Configuration.logger.debug "API called: UserApi#login_user\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" end - return result + return status_code, headers, data end # Logs out current logged in user session @@ -205,6 +246,15 @@ module Petstore # @param [Hash] opts the optional parameters # @return [nil] def logout_user(opts = {}) + logout_user_with_http_info(opts) + return nil + end + + # Logs out current logged in user session + # + # @param [Hash] opts the optional parameters + # @return [Array] response status code, response headers and nil + def logout_user_with_http_info(opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: UserApi#logout_user ..." end @@ -234,16 +284,16 @@ module Petstore auth_names = [] - @api_client.call_api(:GET, path, + status_code, headers, data = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if Configuration.debugging - Configuration.logger.debug "API called: UserApi#logout_user" + Configuration.logger.debug "API called: UserApi#logout_user\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" end - return nil + return status_code, headers, data end # Get user by user name @@ -252,6 +302,16 @@ module Petstore # @param [Hash] opts the optional parameters # @return [User] def get_user_by_name(username, opts = {}) + status_code, headers, data = get_user_by_name_with_http_info(username, opts) + return data + end + + # Get user by user name + # + # @param username The name that needs to be fetched. Use user1 for testing. + # @param [Hash] opts the optional parameters + # @return [Array] response status code, response headers and User data + def get_user_by_name_with_http_info(username, opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: UserApi#get_user_by_name ..." end @@ -284,7 +344,7 @@ module Petstore auth_names = [] - result = @api_client.call_api(:GET, path, + status_code, headers, data = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -292,9 +352,9 @@ module Petstore :auth_names => auth_names, :return_type => 'User') if Configuration.debugging - Configuration.logger.debug "API called: UserApi#get_user_by_name. Result: #{result.inspect}" + Configuration.logger.debug "API called: UserApi#get_user_by_name\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" end - return result + return status_code, headers, data end # Updated user @@ -304,6 +364,17 @@ module Petstore # @option opts [User] :body Updated user object # @return [nil] def update_user(username, opts = {}) + update_user_with_http_info(username, opts) + return nil + end + + # Updated user + # This can only be done by the logged in user. + # @param username name that need to be deleted + # @param [Hash] opts the optional parameters + # @option opts [User] :body Updated user object + # @return [Array] response status code, response headers and nil + def update_user_with_http_info(username, opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: UserApi#update_user ..." end @@ -336,16 +407,16 @@ module Petstore auth_names = [] - @api_client.call_api(:PUT, path, + status_code, headers, data = @api_client.call_api(:PUT, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if Configuration.debugging - Configuration.logger.debug "API called: UserApi#update_user" + Configuration.logger.debug "API called: UserApi#update_user\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" end - return nil + return status_code, headers, data end # Delete user @@ -354,6 +425,16 @@ module Petstore # @param [Hash] opts the optional parameters # @return [nil] def delete_user(username, opts = {}) + delete_user_with_http_info(username, opts) + return nil + end + + # Delete user + # This can only be done by the logged in user. + # @param username The name that needs to be deleted + # @param [Hash] opts the optional parameters + # @return [Array] response status code, response headers and nil + def delete_user_with_http_info(username, opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: UserApi#delete_user ..." end @@ -386,16 +467,16 @@ module Petstore auth_names = [] - @api_client.call_api(:DELETE, path, + status_code, headers, data = @api_client.call_api(:DELETE, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if Configuration.debugging - Configuration.logger.debug "API called: UserApi#delete_user" + Configuration.logger.debug "API called: UserApi#delete_user\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" end - return nil + return status_code, headers, data end end end diff --git a/samples/client/petstore/ruby/lib/petstore/api_client.rb b/samples/client/petstore/ruby/lib/petstore/api_client.rb index 92a61bac4a6..9dfe51ba147 100644 --- a/samples/client/petstore/ruby/lib/petstore/api_client.rb +++ b/samples/client/petstore/ruby/lib/petstore/api_client.rb @@ -15,9 +15,6 @@ module Petstore # @return [Hash] attr_accessor :default_headers - # Stores the HTTP response from the last API call using this API client. - attr_accessor :last_response - def initialize(host = nil) @host = host || Configuration.base_url @format = 'json' @@ -28,13 +25,12 @@ module Petstore } end + # Call an API with given options and an array of 3 elements: + # response status code, response headers and the data deserialized from response body (could be nil). def call_api(http_method, path, opts = {}) request = build_request(http_method, path, opts) response = request.run - # record as last response - @last_response = response - if Configuration.debugging Configuration.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n" end @@ -47,10 +43,11 @@ module Petstore end if opts[:return_type] - deserialize(response, opts[:return_type]) + data = deserialize(response, opts[:return_type]) else - nil + data = nil end + return response.code, response.headers, data end def build_request(http_method, path, opts = {}) diff --git a/samples/client/petstore/ruby/spec/pet_spec.rb b/samples/client/petstore/ruby/spec/pet_spec.rb index 612fc536147..4c6e9180a8a 100644 --- a/samples/client/petstore/ruby/spec/pet_spec.rb +++ b/samples/client/petstore/ruby/spec/pet_spec.rb @@ -50,6 +50,17 @@ describe "Pet" do pet.category.name.should == "category test" end + it "should fetch a pet object with http info" do + status_code, headers, pet = @pet_api.get_pet_by_id_with_http_info(10002) + status_code.should == 200 + headers['Content-Type'].should == 'application/json' + pet.should be_a(Petstore::Pet) + pet.id.should == 10002 + pet.name.should == "RUBY UNIT TESTING" + pet.tags[0].name.should == "tag test" + pet.category.name.should == "category test" + end + it "should not find a pet that does not exist" do begin @pet_api.get_pet_by_id(-10002) From 07de03c09bdebc7abcc3b7383087015810479ccc Mon Sep 17 00:00:00 2001 From: xhh Date: Mon, 7 Dec 2015 16:10:24 +0800 Subject: [PATCH 11/17] Return data before response status code and headers --- .../src/main/resources/ruby/api.mustache | 10 +-- .../main/resources/ruby/api_client.mustache | 8 ++- .../petstore/ruby/lib/petstore/api/pet_api.rb | 70 +++++++++---------- .../ruby/lib/petstore/api/store_api.rb | 38 +++++----- .../ruby/lib/petstore/api/user_api.rb | 68 +++++++++--------- .../petstore/ruby/lib/petstore/api_client.rb | 8 ++- samples/client/petstore/ruby/spec/pet_spec.rb | 2 +- 7 files changed, 104 insertions(+), 100 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/ruby/api.mustache b/modules/swagger-codegen/src/main/resources/ruby/api.mustache index 999aa4a9776..65e00081686 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/api.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/api.mustache @@ -17,7 +17,7 @@ module {{moduleName}} {{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}} {{/required}}{{/allParams}} # @return [{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}] def {{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {}) - {{#returnType}}status_code, headers, data = {{/returnType}}{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts) + {{#returnType}}data, status_code, headers = {{/returnType}}{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts) {{#returnType}}return data{{/returnType}}{{^returnType}}return nil{{/returnType}} end @@ -26,7 +26,7 @@ module {{moduleName}} {{#allParams}}{{#required}} # @param {{paramName}} {{description}} {{/required}}{{/allParams}} # @param [Hash] opts the optional parameters {{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}} -{{/required}}{{/allParams}} # @return [Array] response status code, response headers and {{#returnType}}{{{returnType}}} data{{/returnType}}{{^returnType}}nil{{/returnType}} +{{/required}}{{/allParams}} # @return [Array<({{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}, Fixnum, Hash)>] {{#returnType}}{{{returnType}}} data{{/returnType}}{{^returnType}}nil{{/returnType}}, response status code and response headers def {{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: {{classname}}#{{operationId}} ..." @@ -74,7 +74,7 @@ module {{moduleName}} {{/bodyParam}} auth_names = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}] - status_code, headers, data = @api_client.call_api(:{{httpMethod}}, path, + data, status_code, headers = @api_client.call_api(:{{httpMethod}}, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -82,9 +82,9 @@ module {{moduleName}} :auth_names => auth_names{{#returnType}}, :return_type => '{{{returnType}}}'{{/returnType}}) if Configuration.debugging - Configuration.logger.debug "API called: {{classname}}#{{operationId}}\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" + Configuration.logger.debug "API called: {{classname}}#{{operationId}}\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end - return status_code, headers, data + return data, status_code, headers end {{/operation}} end diff --git a/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache b/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache index b5b67aa21eb..3873d476577 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache @@ -25,8 +25,10 @@ module {{moduleName}} } end - # Call an API with given options and an array of 3 elements: - # response status code, response headers and the data deserialized from response body (could be nil). + # Call an API with given options. + # + # @return [Array<(Object, Fixnum, Hash)>] an array of 3 elements: + # the data deserialized from response body (could be nil), response status code and response headers. def call_api(http_method, path, opts = {}) request = build_request(http_method, path, opts) response = request.run @@ -47,7 +49,7 @@ module {{moduleName}} else data = nil end - return response.code, response.headers, data + return data, response.code, response.headers end def build_request(http_method, path, opts = {}) 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 9e3dcd1dea3..acbd564db53 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb @@ -22,7 +22,7 @@ module Petstore # # @param [Hash] opts the optional parameters # @option opts [Pet] :body Pet object that needs to be added to the store - # @return [Array] response status code, response headers and nil + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def update_pet_with_http_info(opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: PetApi#update_pet ..." @@ -53,16 +53,16 @@ module Petstore auth_names = ['petstore_auth'] - status_code, headers, data = @api_client.call_api(:PUT, path, + data, status_code, headers = @api_client.call_api(:PUT, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if Configuration.debugging - Configuration.logger.debug "API called: PetApi#update_pet\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" + Configuration.logger.debug "API called: PetApi#update_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end - return status_code, headers, data + return data, status_code, headers end # Add a new pet to the store @@ -79,7 +79,7 @@ module Petstore # # @param [Hash] opts the optional parameters # @option opts [Pet] :body Pet object that needs to be added to the store - # @return [Array] response status code, response headers and nil + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def add_pet_with_http_info(opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: PetApi#add_pet ..." @@ -110,16 +110,16 @@ module Petstore auth_names = ['petstore_auth'] - status_code, headers, data = @api_client.call_api(:POST, path, + data, status_code, headers = @api_client.call_api(:POST, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if Configuration.debugging - Configuration.logger.debug "API called: PetApi#add_pet\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" + Configuration.logger.debug "API called: PetApi#add_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end - return status_code, headers, data + return data, status_code, headers end # Finds Pets by status @@ -128,7 +128,7 @@ module Petstore # @option opts [Array] :status Status values that need to be considered for filter # @return [Array] def find_pets_by_status(opts = {}) - status_code, headers, data = find_pets_by_status_with_http_info(opts) + data, status_code, headers = find_pets_by_status_with_http_info(opts) return data end @@ -136,7 +136,7 @@ module Petstore # Multiple status values can be provided with comma seperated strings # @param [Hash] opts the optional parameters # @option opts [Array] :status Status values that need to be considered for filter - # @return [Array>] response status code, response headers and Array data + # @return [Array<(Array, Fixnum, Hash)>] Array data, response status code and response headers def find_pets_by_status_with_http_info(opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: PetApi#find_pets_by_status ..." @@ -168,7 +168,7 @@ module Petstore auth_names = ['petstore_auth'] - status_code, headers, data = @api_client.call_api(:GET, path, + data, status_code, headers = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -176,9 +176,9 @@ module Petstore :auth_names => auth_names, :return_type => 'Array') if Configuration.debugging - Configuration.logger.debug "API called: PetApi#find_pets_by_status\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" + Configuration.logger.debug "API called: PetApi#find_pets_by_status\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end - return status_code, headers, data + return data, status_code, headers end # Finds Pets by tags @@ -187,7 +187,7 @@ module Petstore # @option opts [Array] :tags Tags to filter by # @return [Array] def find_pets_by_tags(opts = {}) - status_code, headers, data = find_pets_by_tags_with_http_info(opts) + data, status_code, headers = find_pets_by_tags_with_http_info(opts) return data end @@ -195,7 +195,7 @@ module Petstore # Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. # @param [Hash] opts the optional parameters # @option opts [Array] :tags Tags to filter by - # @return [Array>] response status code, response headers and Array data + # @return [Array<(Array, Fixnum, Hash)>] Array data, response status code and response headers def find_pets_by_tags_with_http_info(opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: PetApi#find_pets_by_tags ..." @@ -227,7 +227,7 @@ module Petstore auth_names = ['petstore_auth'] - status_code, headers, data = @api_client.call_api(:GET, path, + data, status_code, headers = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -235,9 +235,9 @@ module Petstore :auth_names => auth_names, :return_type => 'Array') if Configuration.debugging - Configuration.logger.debug "API called: PetApi#find_pets_by_tags\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" + Configuration.logger.debug "API called: PetApi#find_pets_by_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end - return status_code, headers, data + return data, status_code, headers end # Find pet by ID @@ -246,7 +246,7 @@ module Petstore # @param [Hash] opts the optional parameters # @return [Pet] def get_pet_by_id(pet_id, opts = {}) - status_code, headers, data = get_pet_by_id_with_http_info(pet_id, opts) + data, status_code, headers = get_pet_by_id_with_http_info(pet_id, opts) return data end @@ -254,7 +254,7 @@ module Petstore # Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions # @param pet_id ID of pet that needs to be fetched # @param [Hash] opts the optional parameters - # @return [Array] response status code, response headers and Pet data + # @return [Array<(Pet, Fixnum, Hash)>] Pet data, response status code and response headers def get_pet_by_id_with_http_info(pet_id, opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: PetApi#get_pet_by_id ..." @@ -288,7 +288,7 @@ module Petstore auth_names = ['api_key'] - status_code, headers, data = @api_client.call_api(:GET, path, + data, status_code, headers = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -296,9 +296,9 @@ module Petstore :auth_names => auth_names, :return_type => 'Pet') if Configuration.debugging - Configuration.logger.debug "API called: PetApi#get_pet_by_id\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" + Configuration.logger.debug "API called: PetApi#get_pet_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end - return status_code, headers, data + return data, status_code, headers end # Updates a pet in the store with form data @@ -319,7 +319,7 @@ module Petstore # @param [Hash] opts the optional parameters # @option opts [String] :name Updated name of the pet # @option opts [String] :status Updated status of the pet - # @return [Array] response status code, response headers and nil + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def update_pet_with_form_with_http_info(pet_id, opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: PetApi#update_pet_with_form ..." @@ -355,16 +355,16 @@ module Petstore auth_names = ['petstore_auth'] - status_code, headers, data = @api_client.call_api(:POST, path, + data, status_code, headers = @api_client.call_api(:POST, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if Configuration.debugging - Configuration.logger.debug "API called: PetApi#update_pet_with_form\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" + Configuration.logger.debug "API called: PetApi#update_pet_with_form\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end - return status_code, headers, data + return data, status_code, headers end # Deletes a pet @@ -383,7 +383,7 @@ module Petstore # @param pet_id Pet id to delete # @param [Hash] opts the optional parameters # @option opts [String] :api_key - # @return [Array] response status code, response headers and nil + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def delete_pet_with_http_info(pet_id, opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: PetApi#delete_pet ..." @@ -418,16 +418,16 @@ module Petstore auth_names = ['petstore_auth'] - status_code, headers, data = @api_client.call_api(:DELETE, path, + data, status_code, headers = @api_client.call_api(:DELETE, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if Configuration.debugging - Configuration.logger.debug "API called: PetApi#delete_pet\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" + Configuration.logger.debug "API called: PetApi#delete_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end - return status_code, headers, data + return data, status_code, headers end # uploads an image @@ -448,7 +448,7 @@ module Petstore # @param [Hash] opts the optional parameters # @option opts [String] :additional_metadata Additional data to pass to server # @option opts [File] :file file to upload - # @return [Array] response status code, response headers and nil + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def upload_file_with_http_info(pet_id, opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: PetApi#upload_file ..." @@ -484,16 +484,16 @@ module Petstore auth_names = ['petstore_auth'] - status_code, headers, data = @api_client.call_api(:POST, path, + data, status_code, headers = @api_client.call_api(:POST, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if Configuration.debugging - Configuration.logger.debug "API called: PetApi#upload_file\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" + Configuration.logger.debug "API called: PetApi#upload_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end - return status_code, headers, data + return data, status_code, headers end end end diff --git a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb index d899d893465..548973eefd3 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb @@ -13,14 +13,14 @@ module Petstore # @param [Hash] opts the optional parameters # @return [Hash] def get_inventory(opts = {}) - status_code, headers, data = get_inventory_with_http_info(opts) + data, status_code, headers = get_inventory_with_http_info(opts) return data end # Returns pet inventories by status # Returns a map of status codes to quantities # @param [Hash] opts the optional parameters - # @return [Array>] response status code, response headers and Hash data + # @return [Array<(Hash, Fixnum, Hash)>] Hash data, response status code and response headers def get_inventory_with_http_info(opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: StoreApi#get_inventory ..." @@ -51,7 +51,7 @@ module Petstore auth_names = ['api_key'] - status_code, headers, data = @api_client.call_api(:GET, path, + data, status_code, headers = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -59,9 +59,9 @@ module Petstore :auth_names => auth_names, :return_type => 'Hash') if Configuration.debugging - Configuration.logger.debug "API called: StoreApi#get_inventory\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" + Configuration.logger.debug "API called: StoreApi#get_inventory\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end - return status_code, headers, data + return data, status_code, headers end # Place an order for a pet @@ -70,7 +70,7 @@ module Petstore # @option opts [Order] :body order placed for purchasing the pet # @return [Order] def place_order(opts = {}) - status_code, headers, data = place_order_with_http_info(opts) + data, status_code, headers = place_order_with_http_info(opts) return data end @@ -78,7 +78,7 @@ module Petstore # # @param [Hash] opts the optional parameters # @option opts [Order] :body order placed for purchasing the pet - # @return [Array] response status code, response headers and Order data + # @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers def place_order_with_http_info(opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: StoreApi#place_order ..." @@ -109,7 +109,7 @@ module Petstore auth_names = [] - status_code, headers, data = @api_client.call_api(:POST, path, + data, status_code, headers = @api_client.call_api(:POST, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -117,9 +117,9 @@ module Petstore :auth_names => auth_names, :return_type => 'Order') if Configuration.debugging - Configuration.logger.debug "API called: StoreApi#place_order\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" + Configuration.logger.debug "API called: StoreApi#place_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end - return status_code, headers, data + return data, status_code, headers end # Find purchase order by ID @@ -128,7 +128,7 @@ module Petstore # @param [Hash] opts the optional parameters # @return [Order] def get_order_by_id(order_id, opts = {}) - status_code, headers, data = get_order_by_id_with_http_info(order_id, opts) + data, status_code, headers = get_order_by_id_with_http_info(order_id, opts) return data end @@ -136,7 +136,7 @@ module Petstore # For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions # @param order_id ID of pet that needs to be fetched # @param [Hash] opts the optional parameters - # @return [Array] response status code, response headers and Order data + # @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers def get_order_by_id_with_http_info(order_id, opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: StoreApi#get_order_by_id ..." @@ -170,7 +170,7 @@ module Petstore auth_names = [] - status_code, headers, data = @api_client.call_api(:GET, path, + data, status_code, headers = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -178,9 +178,9 @@ module Petstore :auth_names => auth_names, :return_type => 'Order') if Configuration.debugging - Configuration.logger.debug "API called: StoreApi#get_order_by_id\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" + Configuration.logger.debug "API called: StoreApi#get_order_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end - return status_code, headers, data + return data, status_code, headers end # Delete purchase order by ID @@ -197,7 +197,7 @@ module Petstore # For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors # @param order_id ID of the order that needs to be deleted # @param [Hash] opts the optional parameters - # @return [Array] response status code, response headers and nil + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def delete_order_with_http_info(order_id, opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: StoreApi#delete_order ..." @@ -231,16 +231,16 @@ module Petstore auth_names = [] - status_code, headers, data = @api_client.call_api(:DELETE, path, + data, status_code, headers = @api_client.call_api(:DELETE, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if Configuration.debugging - Configuration.logger.debug "API called: StoreApi#delete_order\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" + Configuration.logger.debug "API called: StoreApi#delete_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end - return status_code, headers, data + return data, status_code, headers end end end 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 ed32cc37bad..35623175f35 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb @@ -22,7 +22,7 @@ module Petstore # This can only be done by the logged in user. # @param [Hash] opts the optional parameters # @option opts [User] :body Created user object - # @return [Array] response status code, response headers and nil + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def create_user_with_http_info(opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: UserApi#create_user ..." @@ -53,16 +53,16 @@ module Petstore auth_names = [] - status_code, headers, data = @api_client.call_api(:POST, path, + data, status_code, headers = @api_client.call_api(:POST, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if Configuration.debugging - Configuration.logger.debug "API called: UserApi#create_user\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" + Configuration.logger.debug "API called: UserApi#create_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end - return status_code, headers, data + return data, status_code, headers end # Creates list of users with given input array @@ -79,7 +79,7 @@ module Petstore # # @param [Hash] opts the optional parameters # @option opts [Array] :body List of user object - # @return [Array] response status code, response headers and nil + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def create_users_with_array_input_with_http_info(opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: UserApi#create_users_with_array_input ..." @@ -110,16 +110,16 @@ module Petstore auth_names = [] - status_code, headers, data = @api_client.call_api(:POST, path, + data, status_code, headers = @api_client.call_api(:POST, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if Configuration.debugging - Configuration.logger.debug "API called: UserApi#create_users_with_array_input\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" + Configuration.logger.debug "API called: UserApi#create_users_with_array_input\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end - return status_code, headers, data + return data, status_code, headers end # Creates list of users with given input array @@ -136,7 +136,7 @@ module Petstore # # @param [Hash] opts the optional parameters # @option opts [Array] :body List of user object - # @return [Array] response status code, response headers and nil + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def create_users_with_list_input_with_http_info(opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: UserApi#create_users_with_list_input ..." @@ -167,16 +167,16 @@ module Petstore auth_names = [] - status_code, headers, data = @api_client.call_api(:POST, path, + data, status_code, headers = @api_client.call_api(:POST, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if Configuration.debugging - Configuration.logger.debug "API called: UserApi#create_users_with_list_input\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" + Configuration.logger.debug "API called: UserApi#create_users_with_list_input\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end - return status_code, headers, data + return data, status_code, headers end # Logs user into the system @@ -186,7 +186,7 @@ module Petstore # @option opts [String] :password The password for login in clear text # @return [String] def login_user(opts = {}) - status_code, headers, data = login_user_with_http_info(opts) + data, status_code, headers = login_user_with_http_info(opts) return data end @@ -195,7 +195,7 @@ module Petstore # @param [Hash] opts the optional parameters # @option opts [String] :username The user name for login # @option opts [String] :password The password for login in clear text - # @return [Array] response status code, response headers and String data + # @return [Array<(String, Fixnum, Hash)>] String data, response status code and response headers def login_user_with_http_info(opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: UserApi#login_user ..." @@ -228,7 +228,7 @@ module Petstore auth_names = [] - status_code, headers, data = @api_client.call_api(:GET, path, + data, status_code, headers = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -236,9 +236,9 @@ module Petstore :auth_names => auth_names, :return_type => 'String') if Configuration.debugging - Configuration.logger.debug "API called: UserApi#login_user\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" + Configuration.logger.debug "API called: UserApi#login_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end - return status_code, headers, data + return data, status_code, headers end # Logs out current logged in user session @@ -253,7 +253,7 @@ module Petstore # Logs out current logged in user session # # @param [Hash] opts the optional parameters - # @return [Array] response status code, response headers and nil + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def logout_user_with_http_info(opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: UserApi#logout_user ..." @@ -284,16 +284,16 @@ module Petstore auth_names = [] - status_code, headers, data = @api_client.call_api(:GET, path, + data, status_code, headers = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if Configuration.debugging - Configuration.logger.debug "API called: UserApi#logout_user\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" + Configuration.logger.debug "API called: UserApi#logout_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end - return status_code, headers, data + return data, status_code, headers end # Get user by user name @@ -302,7 +302,7 @@ module Petstore # @param [Hash] opts the optional parameters # @return [User] def get_user_by_name(username, opts = {}) - status_code, headers, data = get_user_by_name_with_http_info(username, opts) + data, status_code, headers = get_user_by_name_with_http_info(username, opts) return data end @@ -310,7 +310,7 @@ module Petstore # # @param username The name that needs to be fetched. Use user1 for testing. # @param [Hash] opts the optional parameters - # @return [Array] response status code, response headers and User data + # @return [Array<(User, Fixnum, Hash)>] User data, response status code and response headers def get_user_by_name_with_http_info(username, opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: UserApi#get_user_by_name ..." @@ -344,7 +344,7 @@ module Petstore auth_names = [] - status_code, headers, data = @api_client.call_api(:GET, path, + data, status_code, headers = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, @@ -352,9 +352,9 @@ module Petstore :auth_names => auth_names, :return_type => 'User') if Configuration.debugging - Configuration.logger.debug "API called: UserApi#get_user_by_name\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" + Configuration.logger.debug "API called: UserApi#get_user_by_name\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end - return status_code, headers, data + return data, status_code, headers end # Updated user @@ -373,7 +373,7 @@ module Petstore # @param username name that need to be deleted # @param [Hash] opts the optional parameters # @option opts [User] :body Updated user object - # @return [Array] response status code, response headers and nil + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def update_user_with_http_info(username, opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: UserApi#update_user ..." @@ -407,16 +407,16 @@ module Petstore auth_names = [] - status_code, headers, data = @api_client.call_api(:PUT, path, + data, status_code, headers = @api_client.call_api(:PUT, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if Configuration.debugging - Configuration.logger.debug "API called: UserApi#update_user\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" + Configuration.logger.debug "API called: UserApi#update_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end - return status_code, headers, data + return data, status_code, headers end # Delete user @@ -433,7 +433,7 @@ module Petstore # This can only be done by the logged in user. # @param username The name that needs to be deleted # @param [Hash] opts the optional parameters - # @return [Array] response status code, response headers and nil + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def delete_user_with_http_info(username, opts = {}) if Configuration.debugging Configuration.logger.debug "Calling API: UserApi#delete_user ..." @@ -467,16 +467,16 @@ module Petstore auth_names = [] - status_code, headers, data = @api_client.call_api(:DELETE, path, + data, status_code, headers = @api_client.call_api(:DELETE, path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if Configuration.debugging - Configuration.logger.debug "API called: UserApi#delete_user\nStatus code: #{status_code}\nHeaders: #{headers}\nData: #{data.inspect}" + Configuration.logger.debug "API called: UserApi#delete_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end - return status_code, headers, data + return data, status_code, headers end end end diff --git a/samples/client/petstore/ruby/lib/petstore/api_client.rb b/samples/client/petstore/ruby/lib/petstore/api_client.rb index 9dfe51ba147..412fb7946ad 100644 --- a/samples/client/petstore/ruby/lib/petstore/api_client.rb +++ b/samples/client/petstore/ruby/lib/petstore/api_client.rb @@ -25,8 +25,10 @@ module Petstore } end - # Call an API with given options and an array of 3 elements: - # response status code, response headers and the data deserialized from response body (could be nil). + # Call an API with given options. + # + # @return [Array<(Object, Fixnum, Hash)>] an array of 3 elements: + # the data deserialized from response body (could be nil), response status code and response headers. def call_api(http_method, path, opts = {}) request = build_request(http_method, path, opts) response = request.run @@ -47,7 +49,7 @@ module Petstore else data = nil end - return response.code, response.headers, data + return data, response.code, response.headers end def build_request(http_method, path, opts = {}) diff --git a/samples/client/petstore/ruby/spec/pet_spec.rb b/samples/client/petstore/ruby/spec/pet_spec.rb index 4c6e9180a8a..9426d2024b9 100644 --- a/samples/client/petstore/ruby/spec/pet_spec.rb +++ b/samples/client/petstore/ruby/spec/pet_spec.rb @@ -51,7 +51,7 @@ describe "Pet" do end it "should fetch a pet object with http info" do - status_code, headers, pet = @pet_api.get_pet_by_id_with_http_info(10002) + pet, status_code, headers = @pet_api.get_pet_by_id_with_http_info(10002) status_code.should == 200 headers['Content-Type'].should == 'application/json' pet.should be_a(Petstore::Pet) From 105e3e3327c96d4ed0429c0f25da14327ba5a1f3 Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 7 Dec 2015 16:36:32 +0800 Subject: [PATCH 12/17] Create CONTRIBUTING.md --- CONTRIBUTING.md | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000000..ae5b1fbbfbf --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,60 @@ +## Before submitting an issue + + - Before submitting an issue, search the [open issue](https://github.com/swagger-api/swagger-codegen/issues) and [closed issue](https://github.com/swagger-api/swagger-codegen/issues?q=is%3Aissue+is%3Aclosed) to ensure no one else has reported something similar before. + - The issue should contain details on how to repeat the issue, e.g. + - the Swagger spec for reproducing the issue (:bulb: use [Gist](https://gist.github.com) to share). If the Swagger spec cannot be shared publicly, it will be hard for the community to help + - version of Swagger Codegen + - language (`-l` in the command line, e.g. java, csharp, php) + - You can also make a suggestion or ask a question by opening an "issue" + +## Before submitting a PR + + - Search the [open issue](https://github.com/swagger-api/swagger-codegen/issues) to ensure no one else has reported something similar and no one is actively working on similar proposed change. + - If no one has suggested something similar, open an ["issue"](https://github.com/swagger-api/swagger-codegen/issues) with your suggestion to gather feedback from the community. + +## How to contribute + +### Code generators + +All the code generators can be found in [modules/swagger-codegen/src/main/java/io/swagger/codegen/languages](https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages) + +### Templates + +All the templates ([mustache](https://mustache.github.io/)) can be found in [modules/swagger-codegen/src/main/resources](https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen/src/main/resources). + +For a list of variables available in the template, please refer to this [page](https://github.com/swagger-api/swagger-codegen/wiki/Mustache-Template-Variables) + + +### Style guide +Code change should conform to the programming style guide of the respective langauages: +- C#: https://msdn.microsoft.com/en-us/library/vstudio/ff926074.aspx +- Java: https://google.github.io/styleguide/javaguide.html +- ObjC: https://github.com/NYTimes/objective-c-style-guide +- PHP: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md +- Python: https://www.python.org/dev/peps/pep-0008/ +- Ruby: https://github.com/bbatsov/ruby-style-guide +- TypeScript: https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines + + +For other languages, feel free to suggest. + +You may find the current code base not 100% conform to the coding style and we welcome contributions to fix those. + +### Testing + +To add test cases (optional) covering the change in the code generator, please refer to [modules/swagger-codegen/src/test/java/io/swagger/codegen](https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen/src/test/java/io/swagger/codegen) + +To test the templates, please perform the following: +- Update the [Petstore](http://petstore.swagger.io/) sample by running the shell script under `bin` folder. For example, run `./bin/ruby-petstore.sh` to update the Ruby PetStore API client under [`samples/client/petstore/ruby`](https://github.com/swagger-api/swagger-codegen/tree/master/samples/client/petstore/ruby) (For Windows, the batch files can be found under `bin\windows` folder) +- Run the tests in the sample folder, e.g. in `samples/client/petstore/ruby`, run `mvn integration-test -rf :RubyPetstoreClientTests`. (some languages may not contain unit testing for Petstore and we're looking for contribution from the community to implement those tests) +- Finally, git commit the updated samples files: `git commit -a` + (`git add -A` if added files with new test cases) + +To start the CI tests, you can run `mvn verify -Psamples` (assuming you've all the required tools installed to run tests for different languages) or you can leverage http://travis-ci.org to run the CI tests by adding your own Swagger-Codegen repository. + +### Tips +- Smaller changes are easier to review +- [Optional] For bug fixes, provide a Swagger spec to repeat the issue so that the reviewer can use it to confirm the fix +- Add test case(s) to cover the change +- Document the fix in the code to make the code more readable +- Make sure test cases passed after the change (one way is to leverage https://travis-ci.org/ to run the CI tests) From b4c6fc20cb800cc63d557b9b8e2c0a5023f54652 Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 7 Dec 2015 16:38:07 +0800 Subject: [PATCH 13/17] Update CONTRIBUTING.md --- CONTRIBUTING.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ae5b1fbbfbf..4bef580bb26 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,3 +1,5 @@ +# Guidelines For Contributing + ## Before submitting an issue - Before submitting an issue, search the [open issue](https://github.com/swagger-api/swagger-codegen/issues) and [closed issue](https://github.com/swagger-api/swagger-codegen/issues?q=is%3Aissue+is%3Aclosed) to ensure no one else has reported something similar before. From 9ed5b863c4224b5d0f9cff529345043d11397138 Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 7 Dec 2015 16:58:51 +0800 Subject: [PATCH 14/17] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 8bdb6be693e..e810a0fafc8 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ [![Build Status](https://travis-ci.org/swagger-api/swagger-codegen.png)](https://travis-ci.org/swagger-api/swagger-codegen) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.swagger/swagger-codegen-project/badge.svg?style=plastic)](https://maven-badges.herokuapp.com/maven-central/io.swagger/swagger-codegen-project) +:star::star::star: If you would like to contribute, please refer to [guidelines](https://github.com/swagger-api/swagger-codegen/blob/master/CONTRIBUTING.md) and a list of [open tasks](https://github.com/swagger-api/swagger-codegen/issues?q=is%3Aopen+is%3Aissue+label%3A%22Need+community+contribution%22).:star::star::star: + ## Overview This is the swagger codegen project, which allows generation of client libraries automatically from a Swagger-compliant server. From 0cef7116e8ceb5aa4863b528bb1473a60294d07d Mon Sep 17 00:00:00 2001 From: Lars Mikkelsen Date: Mon, 7 Dec 2015 16:38:37 -0500 Subject: [PATCH 15/17] Replace #import with #include in the Qt5 generator The SWGHelpers.cpp file uses non-standard #import statements. This causes the following error when built using Visual Studio 2013: SWGHelpers.cpp(4): fatal error C1083: Cannot open type library file: 'c:\qt\qt5.5.1\5.5\msvc2013_64\include\qtcore\qdebug': Error loading type library/DLL. --- .../resources/qt5cpp/helpers-body.mustache | 6 ++-- .../petstore/qt5cpp/client/SWGHelpers.cpp | 32 +++++++++++++++++-- .../client/petstore/qt5cpp/client/SWGPet.h | 6 ++-- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-body.mustache b/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-body.mustache index 7bd9b3f46cc..6b439996724 100644 --- a/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-body.mustache +++ b/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-body.mustache @@ -1,9 +1,9 @@ #include "SWGHelpers.h" #include "SWGModelFactory.h" #include "SWGObject.h" -#import -#import -#import +#include +#include +#include namespace Swagger { diff --git a/samples/client/petstore/qt5cpp/client/SWGHelpers.cpp b/samples/client/petstore/qt5cpp/client/SWGHelpers.cpp index 7f4d748c2dc..6b439996724 100644 --- a/samples/client/petstore/qt5cpp/client/SWGHelpers.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGHelpers.cpp @@ -1,9 +1,9 @@ #include "SWGHelpers.h" #include "SWGModelFactory.h" #include "SWGObject.h" -#import -#import -#import +#include +#include +#include namespace Swagger { @@ -25,6 +25,14 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) { qint64 *val = static_cast(value); *val = obj.toVariant().toLongLong(); } + else if(QStringLiteral("float").compare(type) == 0) { + float *val = static_cast(value); + *val = obj.toDouble(); + } + else if(QStringLiteral("double").compare(type) == 0) { + double *val = static_cast(value); + *val = obj.toDouble(); + } else if (QStringLiteral("QString").compare(type) == 0) { QString **val = static_cast(value); @@ -86,6 +94,16 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) { setValue(&val, jval, QStringLiteral("bool"), QStringLiteral("")); output->append((void*)&val); } + else if(QStringLiteral("float").compare(complexType) == 0) { + float val; + setValue(&val, jval, QStringLiteral("float"), QStringLiteral("")); + output->append((void*)&val); + } + else if(QStringLiteral("double").compare(complexType) == 0) { + double val; + setValue(&val, jval, QStringLiteral("double"), QStringLiteral("")); + output->append((void*)&val); + } } } QList **val = static_cast**>(value); @@ -131,6 +149,14 @@ toJsonValue(QString name, void* value, QJsonObject* output, QString type) { bool* str = static_cast(value); output->insert(name, QJsonValue(*str)); } + else if(QStringLiteral("float").compare(type) == 0) { + float* str = static_cast(value); + output->insert(name, QJsonValue((double)*str)); + } + else if(QStringLiteral("double").compare(type) == 0) { + double* str = static_cast(value); + output->insert(name, QJsonValue(*str)); + } } void diff --git a/samples/client/petstore/qt5cpp/client/SWGPet.h b/samples/client/petstore/qt5cpp/client/SWGPet.h index e9cb4d08233..3f9320f1507 100644 --- a/samples/client/petstore/qt5cpp/client/SWGPet.h +++ b/samples/client/petstore/qt5cpp/client/SWGPet.h @@ -10,10 +10,10 @@ #include -#include "SWGTag.h" -#include -#include "SWGCategory.h" #include +#include "SWGCategory.h" +#include +#include "SWGTag.h" #include "SWGObject.h" From f9f0992cc8bdf0817f7e1f5b3a7659111e2da034 Mon Sep 17 00:00:00 2001 From: wing328 Date: Tue, 8 Dec 2015 15:09:30 +0800 Subject: [PATCH 16/17] add default member's value for C# models --- .../languages/CSharpClientCodegen.java | 51 ++++++++++++++++-- .../src/main/resources/csharp/model.mustache | 9 ++++ .../main/csharp/IO/Swagger/Model/Category.cs | 8 +++ .../src/main/csharp/IO/Swagger/Model/Order.cs | 8 +++ .../src/main/csharp/IO/Swagger/Model/Pet.cs | 8 +++ .../src/main/csharp/IO/Swagger/Model/Tag.cs | 8 +++ .../src/main/csharp/IO/Swagger/Model/User.cs | 8 +++ .../SwaggerClientTest.userprefs | 25 ++------- .../bin/Debug/SwaggerClientTest.dll | Bin 98816 -> 98816 bytes .../bin/Debug/SwaggerClientTest.dll.mdb | Bin 29704 -> 29758 bytes .../obj/Debug/SwaggerClientTest.dll | Bin 98816 -> 98816 bytes .../obj/Debug/SwaggerClientTest.dll.mdb | Bin 29704 -> 29758 bytes 12 files changed, 100 insertions(+), 25 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java index be8b4b74781..f69ddd16d35 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java @@ -7,9 +7,7 @@ import io.swagger.codegen.DefaultCodegen; import io.swagger.codegen.SupportingFile; import io.swagger.codegen.CodegenProperty; import io.swagger.codegen.CodegenModel; -import io.swagger.models.properties.ArrayProperty; -import io.swagger.models.properties.MapProperty; -import io.swagger.models.properties.Property; +import io.swagger.models.properties.*; import io.swagger.codegen.CliOption; import java.io.File; @@ -300,4 +298,51 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig } return objs; } + + /** + * Return the default value of the property + * + * @param p Swagger property object + * @return string presentation of the default value of the property + */ + @Override + public String toDefaultValue(Property p) { + if (p instanceof StringProperty) { + StringProperty dp = (StringProperty) p; + if (dp.getDefault() != null) { + return "\"" + dp.getDefault().toString() + "\""; + } + } else if (p instanceof BooleanProperty) { + BooleanProperty dp = (BooleanProperty) p; + if (dp.getDefault() != null) { + return dp.getDefault().toString(); + } + } else if (p instanceof DateProperty) { + // TODO + } else if (p instanceof DateTimeProperty) { + // TODO + } else if (p instanceof DoubleProperty) { + DoubleProperty dp = (DoubleProperty) p; + if (dp.getDefault() != null) { + return dp.getDefault().toString(); + } + } else if (p instanceof FloatProperty) { + FloatProperty dp = (FloatProperty) p; + if (dp.getDefault() != null) { + return dp.getDefault().toString(); + } + } else if (p instanceof IntegerProperty) { + IntegerProperty dp = (IntegerProperty) p; + if (dp.getDefault() != null) { + return dp.getDefault().toString(); + } + } else if (p instanceof LongProperty) { + LongProperty dp = (LongProperty) p; + if (dp.getDefault() != null) { + return dp.getDefault().toString(); + } + } + + return null; + } } diff --git a/modules/swagger-codegen/src/main/resources/csharp/model.mustache b/modules/swagger-codegen/src/main/resources/csharp/model.mustache index 7b7f1a6aea0..faff8d20329 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/model.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/model.mustache @@ -18,6 +18,15 @@ namespace {{packageName}}.Model [DataContract] public class {{classname}} : IEquatable<{{classname}}>{{#parent}}, {{{parent}}}{{/parent}} { + /// + /// Initializes a new instance of the class. + /// + public {{classname}}() + { + {{#vars}}{{#defaultValue}}this.{{name}} = {{{defaultValue}}}; + {{/defaultValue}}{{/vars}} + } + {{#vars}} /// /// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}} diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs index 7d3f0936dce..d9cb6b21005 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs @@ -16,6 +16,14 @@ namespace IO.Swagger.Model [DataContract] public class Category : IEquatable { + /// + /// Initializes a new instance of the class. + /// + public Category() + { + + } + /// /// Gets or Sets Id diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs index 1f786769d55..2191707bd09 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs @@ -16,6 +16,14 @@ namespace IO.Swagger.Model [DataContract] public class Order : IEquatable { + /// + /// Initializes a new instance of the class. + /// + public Order() + { + + } + /// /// Gets or Sets Id diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs index d85d8a8be7e..10c44fb46a7 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs @@ -16,6 +16,14 @@ namespace IO.Swagger.Model [DataContract] public class Pet : IEquatable { + /// + /// Initializes a new instance of the class. + /// + public Pet() + { + + } + /// /// Gets or Sets Id diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs index 8b2cbe08474..93210505bf0 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs @@ -16,6 +16,14 @@ namespace IO.Swagger.Model [DataContract] public class Tag : IEquatable { + /// + /// Initializes a new instance of the class. + /// + public Tag() + { + + } + /// /// Gets or Sets Id diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs index d2c1e3a46eb..1fbd17da993 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs @@ -16,6 +16,14 @@ namespace IO.Swagger.Model [DataContract] public class User : IEquatable { + /// + /// Initializes a new instance of the class. + /// + public User() + { + + } + /// /// Gets or Sets Id diff --git a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs index da9e64e0c90..ab3a8ae3ac4 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs +++ b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs @@ -1,30 +1,11 @@  - + - - - - + + - - - - - - - - - - - - - - - - - diff --git a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll index eb5aee17989464d74610896186219a19d741f7c1..a438e10395475b6b219e30bbe99b06cf8364659c 100755 GIT binary patch delta 1585 zcmY+@S!|3^6bJD8AJh7jhf1rhM5Ht6e611@vAk5Zma3{6HLaG>P$Fn7p$~%iN+)AU z6NyZaP$m-9hbl>hs$eQ()K=6s7$qXMG~%hTChk4=5S_Q*{O@wkz4xp0#n<`b&n4Q1 zh}S{{JA}aD;TER0xow*ohdFIo5F$Zj3nALNPE558`S(woaq?T-zyU_{9{Ya-j4&JlQyT(g>Wo;c=Bc>tYsvddSwNWaW6cMlNH6j-Qor$nZ z=^ST)l+Pn_@tE`;fs|awbOf)dRU+bON>frE23a9mH0_eTTI6Av78R2RlckEu!vt1T z7MhPD)?1n7!^7%xZE?)N2G)01z0_7#yxHKGiG!>p^SIQpkR{~LZ={>n;o<9f;H1@mwHFi-520jr;tBCbzgwA>q-%!x-UQuNp;`pn1gp=ovH2%VUGy4 zzn{7ykB=nXeF^$*QrXmf35+f!-F*qhkyQ7W zoC^@Xr8CvN8;5U8S=_xFK}GJ~jSiOT-itW71+;;%B%tbR;v8CD$&ZykQ-K_o%L4E zTY?@|pPaV@F;>61#jzCqthmg2DbcN(knc}@zg`sIr=IB8yjVlh$L2)?Ngdl0=Q6|| z>WS(OtMIdj=FtPLLgFL6N^)kks6vc2l4LyAnS(UyiPmI`Soc)3jMVTm-h1vL>f8PDzaQt^ z`)*U%*%Ws6q&ZUNXN2hdLkJxI(8k(6zvJr;W2s{qgjlqq@7m969VrVEeW}09C%*~P zx{oEj6?UF}XKdov)%o`5MIpb4amKUM{Rw7SXFV&W=2(p%)QXL8UeY5kcP06efKGv+v3gKtXc@DWZqlWd&(=64%a#}6!Eofz>Tc@O=1GbP~#K^X4 zMG<;A{K%@8>SwL7y4{~*lC{P9T`ED+-TN>fVojmg;Z^CRwV(9Y~OLF{P-!N~=&Y zr8q*;#gw9xq>33aze3$LHPY69VgNUY`YHmL(xO)pz*CkgCV&^LmpQef46eUuLt~LF zrVQDvs64fDe9Vf;Q!7Ui>#WQw5Y)1bK^a!y0EgFQxD!WNQ!?9$7FMQwT$PBia^!}U z=wZ#udAl&inv?T(AY$W~q6S{QuPZtwPa_H^)|mYLY&-DuhYu*e1+9 zh>xq0`qYB>?;n~+&o>C;rd}l@Hzb0HvzCxVTxV`l#)MYBO>CUhEF*<)Y3(OPr?d`} z9Z zvPpF_3tKF91ks{p98Hd;??sICozaqcA!9FkI2%pAo}CrK7>6e^T}wiUb690Gzqb!h q`nvvIelV?K`>GAIDD?hRpH+QledPOdiE<3&IMs$ioICXmLeAHu^^0o& diff --git a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb index 073b96f23b3261d5b6d69bd35e415e63676664f6..79928c469eefc5b9dd5855b9f9a878e943a46164 100644 GIT binary patch delta 7928 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 PBHRjYF-?EK|JwfpnUu=q delta 7755 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 U=kae~3Hcd61&>eHMh0H}AE2MMWB>pF diff --git a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll index eb5aee17989464d74610896186219a19d741f7c1..a438e10395475b6b219e30bbe99b06cf8364659c 100755 GIT binary patch delta 1585 zcmY+@S!|3^6bJD8AJh7jhf1rhM5Ht6e611@vAk5Zma3{6HLaG>P$Fn7p$~%iN+)AU z6NyZaP$m-9hbl>hs$eQ()K=6s7$qXMG~%hTChk4=5S_Q*{O@wkz4xp0#n<`b&n4Q1 zh}S{{JA}aD;TER0xow*ohdFIo5F$Zj3nALNPE558`S(woaq?T-zyU_{9{Ya-j4&JlQyT(g>Wo;c=Bc>tYsvddSwNWaW6cMlNH6j-Qor$nZ z=^ST)l+Pn_@tE`;fs|awbOf)dRU+bON>frE23a9mH0_eTTI6Av78R2RlckEu!vt1T z7MhPD)?1n7!^7%xZE?)N2G)01z0_7#yxHKGiG!>p^SIQpkR{~LZ={>n;o<9f;H1@mwHFi-520jr;tBCbzgwA>q-%!x-UQuNp;`pn1gp=ovH2%VUGy4 zzn{7ykB=nXeF^$*QrXmf35+f!-F*qhkyQ7W zoC^@Xr8CvN8;5U8S=_xFK}GJ~jSiOT-itW71+;;%B%tbR;v8CD$&ZykQ-K_o%L4E zTY?@|pPaV@F;>61#jzCqthmg2DbcN(knc}@zg`sIr=IB8yjVlh$L2)?Ngdl0=Q6|| z>WS(OtMIdj=FtPLLgFL6N^)kks6vc2l4LyAnS(UyiPmI`Soc)3jMVTm-h1vL>f8PDzaQt^ z`)*U%*%Ws6q&ZUNXN2hdLkJxI(8k(6zvJr;W2s{qgjlqq@7m969VrVEeW}09C%*~P zx{oEj6?UF}XKdov)%o`5MIpb4amKUM{Rw7SXFV&W=2(p%)QXL8UeY5kcP06efKGv+v3gKtXc@DWZqlWd&(=64%a#}6!Eofz>Tc@O=1GbP~#K^X4 zMG<;A{K%@8>SwL7y4{~*lC{P9T`ED+-TN>fVojmg;Z^CRwV(9Y~OLF{P-!N~=&Y zr8q*;#gw9xq>33aze3$LHPY69VgNUY`YHmL(xO)pz*CkgCV&^LmpQef46eUuLt~LF zrVQDvs64fDe9Vf;Q!7Ui>#WQw5Y)1bK^a!y0EgFQxD!WNQ!?9$7FMQwT$PBia^!}U z=wZ#udAl&inv?T(AY$W~q6S{QuPZtwPa_H^)|mYLY&-DuhYu*e1+9 zh>xq0`qYB>?;n~+&o>C;rd}l@Hzb0HvzCxVTxV`l#)MYBO>CUhEF*<)Y3(OPr?d`} z9Z zvPpF_3tKF91ks{p98Hd;??sICozaqcA!9FkI2%pAo}CrK7>6e^T}wiUb690Gzqb!h q`nvvIelV?K`>GAIDD?hRpH+QledPOdiE<3&IMs$ioICXmLeAHu^^0o& diff --git a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb index 073b96f23b3261d5b6d69bd35e415e63676664f6..79928c469eefc5b9dd5855b9f9a878e943a46164 100644 GIT binary patch delta 7928 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 PBHRjYF-?EK|JwfpnUu=q delta 7755 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 U=kae~3Hcd61&>eHMh0H}AE2MMWB>pF From bf63be3a6322417433b095ce7e99f02f892991d8 Mon Sep 17 00:00:00 2001 From: wing328 Date: Tue, 8 Dec 2015 17:23:54 +0800 Subject: [PATCH 17/17] improve cpp test case --- .../petstore/qt5cpp/PetStore/PetApiTests.cpp | 24 +------------- .../petstore/qt5cpp/PetStore/PetApiTests.h | 1 - .../qt5cpp/PetStore/PetStore.pro.user | 32 ++++++++++--------- 3 files changed, 18 insertions(+), 39 deletions(-) diff --git a/samples/client/petstore/qt5cpp/PetStore/PetApiTests.cpp b/samples/client/petstore/qt5cpp/PetStore/PetApiTests.cpp index 829fbe92640..e2d0ffb5d37 100644 --- a/samples/client/petstore/qt5cpp/PetStore/PetApiTests.cpp +++ b/samples/client/petstore/qt5cpp/PetStore/PetApiTests.cpp @@ -35,34 +35,12 @@ void PetApiTests::runTests() { delete tests; } -void PetApiTests::getPetByIdTest() { - SWGPetApi* api = getApi(); - - static QEventLoop loop; - QTimer timer; - timer.setInterval(1000); - timer.setSingleShot(true); - - auto validator = [](SWGPet* pet) { - QVERIFY(pet->getId() == 3); - loop.quit(); - }; - - connect(api, &SWGPetApi::getPetByIdSignal, this, validator); - connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); - api->getPetById(3); - timer.start(); - loop.exec(); - QVERIFY2(timer.isActive(), "didn't finish within timeout"); - delete api; -} - void PetApiTests::findPetsByStatusTest() { SWGPetApi* api = getApi(); static QEventLoop loop; QTimer timer; - timer.setInterval(1000); + timer.setInterval(4000); timer.setSingleShot(true); auto validator = [](QList* pets) { diff --git a/samples/client/petstore/qt5cpp/PetStore/PetApiTests.h b/samples/client/petstore/qt5cpp/PetStore/PetApiTests.h index 9fdc939ab11..e219bb9a639 100644 --- a/samples/client/petstore/qt5cpp/PetStore/PetApiTests.h +++ b/samples/client/petstore/qt5cpp/PetStore/PetApiTests.h @@ -25,7 +25,6 @@ signals: bool success(); private slots: - void getPetByIdTest(); void findPetsByStatusTest(); void createAndGetPetTest(); void updatePetTest(); diff --git a/samples/client/petstore/qt5cpp/PetStore/PetStore.pro.user b/samples/client/petstore/qt5cpp/PetStore/PetStore.pro.user index a506d15a1d1..c8f28a4d2b1 100644 --- a/samples/client/petstore/qt5cpp/PetStore/PetStore.pro.user +++ b/samples/client/petstore/qt5cpp/PetStore/PetStore.pro.user @@ -1,10 +1,10 @@ - + EnvironmentId - {e1009bf2-3b8d-440a-a972-23a1fd0a9453} + {20946a4e-8558-4260-a72e-14a8108ad944} ProjectExplorer.Project.ActiveTarget @@ -58,14 +58,14 @@ ProjectExplorer.Project.Target.0 - Desktop Qt 5.4.1 clang 64bit - Desktop Qt 5.4.1 clang 64bit - qt.54.clang_64_kit + Desktop Qt 5.5.1 clang 64bit + Desktop Qt 5.5.1 clang 64bit + qt.55.clang_64_kit 0 0 0 - /Users/tony/dev/projects/swagger-api/swagger-codegen/samples/client/petstore/qt5cpp/build-PetStore-Desktop_Qt_5_4_1_clang_64bit-Debug + /Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/qt5cpp/build-PetStore-Desktop_Qt_5_5_1_clang_64bit-Debug true @@ -76,6 +76,7 @@ true false + false false @@ -125,7 +126,7 @@ true - /Users/tony/dev/projects/swagger-api/swagger-codegen/samples/client/petstore/qt5cpp/build-PetStore-Desktop_Qt_5_4_1_clang_64bit-Release + /Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/qt5cpp/build-PetStore-Desktop_Qt_5_5_1_clang_64bit-Release true @@ -136,6 +137,7 @@ true false + false false @@ -216,12 +218,10 @@ true false true - /usr/local/bin/valgrind + valgrind - 11 - 14 - 12 - 13 + 0 + 1 2 3 4 @@ -231,14 +231,16 @@ 8 9 10 - 0 - 1 + 11 + 12 + 13 + 14 2 PetStore - Qt4ProjectManager.Qt4RunConfiguration:/Users/tony/dev/projects/swagger-api/swagger-codegen/samples/client/petstore/qt5cpp/PetStore/PetStore.pro + Qt4ProjectManager.Qt4RunConfiguration:/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/qt5cpp/PetStore/PetStore.pro PetStore.pro false