From cb2f5d3e25467d56aa8e449368c8a2afd6046c08 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 8 Apr 2015 11:33:09 +0800 Subject: [PATCH 1/3] fix php warning in php5.3 --- .../src/main/resources/php/APIClient.mustache | 25 +++-- .../src/main/resources/php/api.mustache | 12 ++- .../php/SwaggerPetstore-php/lib/APIClient.php | 25 +++-- .../php/SwaggerPetstore-php/lib/PetApi.php | 96 ++++++++++++------- .../php/SwaggerPetstore-php/lib/StoreApi.php | 48 ++++++---- .../php/SwaggerPetstore-php/lib/UserApi.php | 96 ++++++++++++------- .../lib/models/Category.php | 2 +- 7 files changed, 201 insertions(+), 103 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/php/APIClient.mustache b/modules/swagger-codegen/src/main/resources/php/APIClient.mustache index 4e60cf6d338..6ac31adeee0 100644 --- a/modules/swagger-codegen/src/main/resources/php/APIClient.mustache +++ b/modules/swagger-codegen/src/main/resources/php/APIClient.mustache @@ -25,6 +25,16 @@ class APIClient { public static $PUT = "PUT"; public static $DELETE = "DELETE"; + /* + * @var string timeout (second) of the HTTP request, by default set to 0, no timeout + */ + protected $curl_timeout = 0; + + /* + * @var string user agent of the HTTP request, set to "PHP-Swagger" by default + */ + protected $user_agent = "PHP-Swagger"; + /** * @param string $host the address of the API server * @param string $headerName a header to pass on requests @@ -54,7 +64,7 @@ class APIClient { if (!is_numeric($seconds)) { throw new Exception('Timeout variable must be numeric.'); } - $this->curl_timout = $seconds; + $this->curl_timeout = $seconds; } /** @@ -84,15 +94,16 @@ class APIClient { $headers[] = $this->headerName . ": " . $this->headerValue; } - if (strpos($headers['Content-Type'], "multipart/form-data") < 0 and (is_object($postData) or is_array($postData))) { + if ((isset($headers['Content-Type']) and strpos($headers['Content-Type'], "multipart/form-data")) < 0 and (is_object($postData) or is_array($postData))) { $postData = json_encode($this->sanitizeForSerialization($postData)); } $url = $this->host . $resourcePath; $curl = curl_init(); - if ($this->curl_timout) { - curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timout); + // set timeout, if needed + if ($this->curl_timeout != 0) { + curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timeout); } // return the result on success, rather than just TRUE curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); @@ -120,11 +131,7 @@ class APIClient { curl_setopt($curl, CURLOPT_URL, $url); // Set user agent - if ($this->user_agent) { - curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent); - } else { // use PHP-Swagger as the default user agent - curl_setopt($curl, CURLOPT_USERAGENT, 'PHP-Swagger'); - } + curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent); // Make the request $response = curl_exec($curl); diff --git a/modules/swagger-codegen/src/main/resources/php/api.mustache b/modules/swagger-codegen/src/main/resources/php/api.mustache index ca1bf24438d..6acb2e87433 100644 --- a/modules/swagger-codegen/src/main/resources/php/api.mustache +++ b/modules/swagger-codegen/src/main/resources/php/api.mustache @@ -44,6 +44,7 @@ class {{classname}} { $resourcePath = "{{path}}"; $resourcePath = str_replace("{format}", "json", $resourcePath); $method = "{{httpMethod}}"; + $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); @@ -77,16 +78,19 @@ class {{classname}} { $body = ${{paramName}}; }{{/bodyParams}} + // for model (json/xml) + if (isset($body)) { + $httpBody = $body; // $body is the method argument, if present + } + // for HTTP post (form) - $body = $body ?: $formParams; - if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { - $body = http_build_query($body); + $httpBody = http_build_query($formParams); } // make the API Call $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $body, + $queryParams, $httpBody, $headerParams); {{#returnType}}if(! $response) { diff --git a/samples/client/petstore/php/SwaggerPetstore-php/lib/APIClient.php b/samples/client/petstore/php/SwaggerPetstore-php/lib/APIClient.php index 1f72299756f..923aa3f87d1 100644 --- a/samples/client/petstore/php/SwaggerPetstore-php/lib/APIClient.php +++ b/samples/client/petstore/php/SwaggerPetstore-php/lib/APIClient.php @@ -25,6 +25,16 @@ class APIClient { public static $PUT = "PUT"; public static $DELETE = "DELETE"; + /* + * @var string timeout (second) of the HTTP request, by default set to 0, no timeout + */ + protected $curl_timeout = 0; + + /* + * @var string user agent of the HTTP request, set to "PHP-Swagger" by default + */ + protected $user_agent = "PHP-Swagger"; + /** * @param string $host the address of the API server * @param string $headerName a header to pass on requests @@ -54,7 +64,7 @@ class APIClient { if (!is_numeric($seconds)) { throw new Exception('Timeout variable must be numeric.'); } - $this->curl_timout = $seconds; + $this->curl_timeout = $seconds; } /** @@ -84,15 +94,16 @@ class APIClient { $headers[] = $this->headerName . ": " . $this->headerValue; } - if (strpos($headers['Content-Type'], "multipart/form-data") < 0 and (is_object($postData) or is_array($postData))) { + if ((isset($headers['Content-Type']) and strpos($headers['Content-Type'], "multipart/form-data")) < 0 and (is_object($postData) or is_array($postData))) { $postData = json_encode($this->sanitizeForSerialization($postData)); } $url = $this->host . $resourcePath; $curl = curl_init(); - if ($this->curl_timout) { - curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timout); + // set timeout, if needed + if ($this->curl_timeout != 0) { + curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timeout); } // return the result on success, rather than just TRUE curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); @@ -120,11 +131,7 @@ class APIClient { curl_setopt($curl, CURLOPT_URL, $url); // Set user agent - if ($this->user_agent) { - curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent); - } else { // use PHP-Swagger as the default user agent - curl_setopt($curl, CURLOPT_USERAGENT, 'PHP-Swagger'); - } + curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent); // Make the request $response = curl_exec($curl); diff --git a/samples/client/petstore/php/SwaggerPetstore-php/lib/PetApi.php b/samples/client/petstore/php/SwaggerPetstore-php/lib/PetApi.php index 7a885b45b82..1b31db8915d 100644 --- a/samples/client/petstore/php/SwaggerPetstore-php/lib/PetApi.php +++ b/samples/client/petstore/php/SwaggerPetstore-php/lib/PetApi.php @@ -43,6 +43,7 @@ class PetApi { $resourcePath = "/pet"; $resourcePath = str_replace("{format}", "json", $resourcePath); $method = "PUT"; + $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); @@ -63,16 +64,19 @@ class PetApi { $body = $body; } + // for model (json/xml) + if (isset($body)) { + $httpBody = $body; // $body is the method argument, if present + } + // for HTTP post (form) - $body = $body ?: $formParams; - if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { - $body = http_build_query($body); + $httpBody = http_build_query($formParams); } // make the API Call $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $body, + $queryParams, $httpBody, $headerParams); @@ -92,6 +96,7 @@ class PetApi { $resourcePath = "/pet"; $resourcePath = str_replace("{format}", "json", $resourcePath); $method = "POST"; + $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); @@ -112,16 +117,19 @@ class PetApi { $body = $body; } + // for model (json/xml) + if (isset($body)) { + $httpBody = $body; // $body is the method argument, if present + } + // for HTTP post (form) - $body = $body ?: $formParams; - if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { - $body = http_build_query($body); + $httpBody = http_build_query($formParams); } // make the API Call $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $body, + $queryParams, $httpBody, $headerParams); @@ -141,6 +149,7 @@ class PetApi { $resourcePath = "/pet/findByStatus"; $resourcePath = str_replace("{format}", "json", $resourcePath); $method = "GET"; + $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); @@ -160,16 +169,19 @@ class PetApi { + // for model (json/xml) + if (isset($body)) { + $httpBody = $body; // $body is the method argument, if present + } + // for HTTP post (form) - $body = $body ?: $formParams; - if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { - $body = http_build_query($body); + $httpBody = http_build_query($formParams); } // make the API Call $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $body, + $queryParams, $httpBody, $headerParams); if(! $response) { @@ -195,6 +207,7 @@ class PetApi { $resourcePath = "/pet/findByTags"; $resourcePath = str_replace("{format}", "json", $resourcePath); $method = "GET"; + $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); @@ -214,16 +227,19 @@ class PetApi { + // for model (json/xml) + if (isset($body)) { + $httpBody = $body; // $body is the method argument, if present + } + // for HTTP post (form) - $body = $body ?: $formParams; - if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { - $body = http_build_query($body); + $httpBody = http_build_query($formParams); } // make the API Call $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $body, + $queryParams, $httpBody, $headerParams); if(! $response) { @@ -249,6 +265,7 @@ class PetApi { $resourcePath = "/pet/{petId}"; $resourcePath = str_replace("{format}", "json", $resourcePath); $method = "GET"; + $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); @@ -269,16 +286,19 @@ class PetApi { + // for model (json/xml) + if (isset($body)) { + $httpBody = $body; // $body is the method argument, if present + } + // for HTTP post (form) - $body = $body ?: $formParams; - if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { - $body = http_build_query($body); + $httpBody = http_build_query($formParams); } // make the API Call $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $body, + $queryParams, $httpBody, $headerParams); if(! $response) { @@ -306,6 +326,7 @@ class PetApi { $resourcePath = "/pet/{petId}"; $resourcePath = str_replace("{format}", "json", $resourcePath); $method = "POST"; + $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); @@ -332,16 +353,19 @@ class PetApi { } + // for model (json/xml) + if (isset($body)) { + $httpBody = $body; // $body is the method argument, if present + } + // for HTTP post (form) - $body = $body ?: $formParams; - if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { - $body = http_build_query($body); + $httpBody = http_build_query($formParams); } // make the API Call $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $body, + $queryParams, $httpBody, $headerParams); @@ -362,6 +386,7 @@ class PetApi { $resourcePath = "/pet/{petId}"; $resourcePath = str_replace("{format}", "json", $resourcePath); $method = "DELETE"; + $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); @@ -385,16 +410,19 @@ class PetApi { + // for model (json/xml) + if (isset($body)) { + $httpBody = $body; // $body is the method argument, if present + } + // for HTTP post (form) - $body = $body ?: $formParams; - if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { - $body = http_build_query($body); + $httpBody = http_build_query($formParams); } // make the API Call $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $body, + $queryParams, $httpBody, $headerParams); @@ -416,6 +444,7 @@ class PetApi { $resourcePath = "/pet/{petId}/uploadImage"; $resourcePath = str_replace("{format}", "json", $resourcePath); $method = "POST"; + $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); @@ -442,16 +471,19 @@ class PetApi { } + // for model (json/xml) + if (isset($body)) { + $httpBody = $body; // $body is the method argument, if present + } + // for HTTP post (form) - $body = $body ?: $formParams; - if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { - $body = http_build_query($body); + $httpBody = http_build_query($formParams); } // make the API Call $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $body, + $queryParams, $httpBody, $headerParams); diff --git a/samples/client/petstore/php/SwaggerPetstore-php/lib/StoreApi.php b/samples/client/petstore/php/SwaggerPetstore-php/lib/StoreApi.php index 90fb0f4d4f8..83a3f0520fa 100644 --- a/samples/client/petstore/php/SwaggerPetstore-php/lib/StoreApi.php +++ b/samples/client/petstore/php/SwaggerPetstore-php/lib/StoreApi.php @@ -42,6 +42,7 @@ class StoreApi { $resourcePath = "/store/inventory"; $resourcePath = str_replace("{format}", "json", $resourcePath); $method = "GET"; + $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); @@ -58,16 +59,19 @@ class StoreApi { + // for model (json/xml) + if (isset($body)) { + $httpBody = $body; // $body is the method argument, if present + } + // for HTTP post (form) - $body = $body ?: $formParams; - if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { - $body = http_build_query($body); + $httpBody = http_build_query($formParams); } // make the API Call $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $body, + $queryParams, $httpBody, $headerParams); if(! $response) { @@ -93,6 +97,7 @@ class StoreApi { $resourcePath = "/store/order"; $resourcePath = str_replace("{format}", "json", $resourcePath); $method = "POST"; + $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); @@ -113,16 +118,19 @@ class StoreApi { $body = $body; } + // for model (json/xml) + if (isset($body)) { + $httpBody = $body; // $body is the method argument, if present + } + // for HTTP post (form) - $body = $body ?: $formParams; - if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { - $body = http_build_query($body); + $httpBody = http_build_query($formParams); } // make the API Call $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $body, + $queryParams, $httpBody, $headerParams); if(! $response) { @@ -148,6 +156,7 @@ class StoreApi { $resourcePath = "/store/order/{orderId}"; $resourcePath = str_replace("{format}", "json", $resourcePath); $method = "GET"; + $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); @@ -168,16 +177,19 @@ class StoreApi { + // for model (json/xml) + if (isset($body)) { + $httpBody = $body; // $body is the method argument, if present + } + // for HTTP post (form) - $body = $body ?: $formParams; - if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { - $body = http_build_query($body); + $httpBody = http_build_query($formParams); } // make the API Call $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $body, + $queryParams, $httpBody, $headerParams); if(! $response) { @@ -203,6 +215,7 @@ class StoreApi { $resourcePath = "/store/order/{orderId}"; $resourcePath = str_replace("{format}", "json", $resourcePath); $method = "DELETE"; + $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); @@ -223,16 +236,19 @@ class StoreApi { + // for model (json/xml) + if (isset($body)) { + $httpBody = $body; // $body is the method argument, if present + } + // for HTTP post (form) - $body = $body ?: $formParams; - if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { - $body = http_build_query($body); + $httpBody = http_build_query($formParams); } // make the API Call $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $body, + $queryParams, $httpBody, $headerParams); diff --git a/samples/client/petstore/php/SwaggerPetstore-php/lib/UserApi.php b/samples/client/petstore/php/SwaggerPetstore-php/lib/UserApi.php index f6952074f7b..d55b430d7a1 100644 --- a/samples/client/petstore/php/SwaggerPetstore-php/lib/UserApi.php +++ b/samples/client/petstore/php/SwaggerPetstore-php/lib/UserApi.php @@ -43,6 +43,7 @@ class UserApi { $resourcePath = "/user"; $resourcePath = str_replace("{format}", "json", $resourcePath); $method = "POST"; + $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); @@ -63,16 +64,19 @@ class UserApi { $body = $body; } + // for model (json/xml) + if (isset($body)) { + $httpBody = $body; // $body is the method argument, if present + } + // for HTTP post (form) - $body = $body ?: $formParams; - if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { - $body = http_build_query($body); + $httpBody = http_build_query($formParams); } // make the API Call $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $body, + $queryParams, $httpBody, $headerParams); @@ -92,6 +96,7 @@ class UserApi { $resourcePath = "/user/createWithArray"; $resourcePath = str_replace("{format}", "json", $resourcePath); $method = "POST"; + $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); @@ -112,16 +117,19 @@ class UserApi { $body = $body; } + // for model (json/xml) + if (isset($body)) { + $httpBody = $body; // $body is the method argument, if present + } + // for HTTP post (form) - $body = $body ?: $formParams; - if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { - $body = http_build_query($body); + $httpBody = http_build_query($formParams); } // make the API Call $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $body, + $queryParams, $httpBody, $headerParams); @@ -141,6 +149,7 @@ class UserApi { $resourcePath = "/user/createWithList"; $resourcePath = str_replace("{format}", "json", $resourcePath); $method = "POST"; + $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); @@ -161,16 +170,19 @@ class UserApi { $body = $body; } + // for model (json/xml) + if (isset($body)) { + $httpBody = $body; // $body is the method argument, if present + } + // for HTTP post (form) - $body = $body ?: $formParams; - if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { - $body = http_build_query($body); + $httpBody = http_build_query($formParams); } // make the API Call $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $body, + $queryParams, $httpBody, $headerParams); @@ -191,6 +203,7 @@ class UserApi { $resourcePath = "/user/login"; $resourcePath = str_replace("{format}", "json", $resourcePath); $method = "GET"; + $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); @@ -213,16 +226,19 @@ class UserApi { + // for model (json/xml) + if (isset($body)) { + $httpBody = $body; // $body is the method argument, if present + } + // for HTTP post (form) - $body = $body ?: $formParams; - if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { - $body = http_build_query($body); + $httpBody = http_build_query($formParams); } // make the API Call $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $body, + $queryParams, $httpBody, $headerParams); if(! $response) { @@ -247,6 +263,7 @@ class UserApi { $resourcePath = "/user/logout"; $resourcePath = str_replace("{format}", "json", $resourcePath); $method = "GET"; + $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); @@ -263,16 +280,19 @@ class UserApi { + // for model (json/xml) + if (isset($body)) { + $httpBody = $body; // $body is the method argument, if present + } + // for HTTP post (form) - $body = $body ?: $formParams; - if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { - $body = http_build_query($body); + $httpBody = http_build_query($formParams); } // make the API Call $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $body, + $queryParams, $httpBody, $headerParams); @@ -292,6 +312,7 @@ class UserApi { $resourcePath = "/user/{username}"; $resourcePath = str_replace("{format}", "json", $resourcePath); $method = "GET"; + $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); @@ -312,16 +333,19 @@ class UserApi { + // for model (json/xml) + if (isset($body)) { + $httpBody = $body; // $body is the method argument, if present + } + // for HTTP post (form) - $body = $body ?: $formParams; - if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { - $body = http_build_query($body); + $httpBody = http_build_query($formParams); } // make the API Call $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $body, + $queryParams, $httpBody, $headerParams); if(! $response) { @@ -348,6 +372,7 @@ class UserApi { $resourcePath = "/user/{username}"; $resourcePath = str_replace("{format}", "json", $resourcePath); $method = "PUT"; + $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); @@ -372,16 +397,19 @@ class UserApi { $body = $body; } + // for model (json/xml) + if (isset($body)) { + $httpBody = $body; // $body is the method argument, if present + } + // for HTTP post (form) - $body = $body ?: $formParams; - if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { - $body = http_build_query($body); + $httpBody = http_build_query($formParams); } // make the API Call $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $body, + $queryParams, $httpBody, $headerParams); @@ -401,6 +429,7 @@ class UserApi { $resourcePath = "/user/{username}"; $resourcePath = str_replace("{format}", "json", $resourcePath); $method = "DELETE"; + $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); @@ -421,16 +450,19 @@ class UserApi { + // for model (json/xml) + if (isset($body)) { + $httpBody = $body; // $body is the method argument, if present + } + // for HTTP post (form) - $body = $body ?: $formParams; - if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { - $body = http_build_query($body); + $httpBody = http_build_query($formParams); } // make the API Call $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $body, + $queryParams, $httpBody, $headerParams); diff --git a/samples/client/petstore/php/SwaggerPetstore-php/lib/models/Category.php b/samples/client/petstore/php/SwaggerPetstore-php/lib/models/Category.php index 2bd2410268c..101222b4503 100644 --- a/samples/client/petstore/php/SwaggerPetstore-php/lib/models/Category.php +++ b/samples/client/petstore/php/SwaggerPetstore-php/lib/models/Category.php @@ -16,7 +16,7 @@ */ /** - * testing category description + * * * NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. * From eb0fccd1d2bf369c057b47c65f30ebfd160294a2 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 8 Apr 2015 11:54:57 +0800 Subject: [PATCH 2/3] fixed content-type check for model --- .../swagger-codegen/src/main/resources/php/APIClient.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/php/APIClient.mustache b/modules/swagger-codegen/src/main/resources/php/APIClient.mustache index 6ac31adeee0..3af1fcbad34 100644 --- a/modules/swagger-codegen/src/main/resources/php/APIClient.mustache +++ b/modules/swagger-codegen/src/main/resources/php/APIClient.mustache @@ -94,7 +94,7 @@ class APIClient { $headers[] = $this->headerName . ": " . $this->headerValue; } - if ((isset($headers['Content-Type']) and strpos($headers['Content-Type'], "multipart/form-data")) < 0 and (is_object($postData) or is_array($postData))) { + if ((isset($headers['Content-Type']) and strpos($headers['Content-Type'], "multipart/form-data") < 0) and (is_object($postData) or is_array($postData))) { $postData = json_encode($this->sanitizeForSerialization($postData)); } From 9de22c8146e3a6439334149935a27dd1545c10d3 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 8 Apr 2015 12:00:37 +0800 Subject: [PATCH 3/3] update petstore php sample --- .../client/petstore/php/SwaggerPetstore-php/lib/APIClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/client/petstore/php/SwaggerPetstore-php/lib/APIClient.php b/samples/client/petstore/php/SwaggerPetstore-php/lib/APIClient.php index 923aa3f87d1..f5a1ec18a33 100644 --- a/samples/client/petstore/php/SwaggerPetstore-php/lib/APIClient.php +++ b/samples/client/petstore/php/SwaggerPetstore-php/lib/APIClient.php @@ -94,7 +94,7 @@ class APIClient { $headers[] = $this->headerName . ": " . $this->headerValue; } - if ((isset($headers['Content-Type']) and strpos($headers['Content-Type'], "multipart/form-data")) < 0 and (is_object($postData) or is_array($postData))) { + if ((isset($headers['Content-Type']) and strpos($headers['Content-Type'], "multipart/form-data") < 0) and (is_object($postData) or is_array($postData))) { $postData = json_encode($this->sanitizeForSerialization($postData)); }