diff --git a/src/main/resources/php/Swagger.mustache b/src/main/resources/php/Swagger.mustache index 962cc53455f..a176b68aa0d 100644 --- a/src/main/resources/php/Swagger.mustache +++ b/src/main/resources/php/Swagger.mustache @@ -77,7 +77,8 @@ class APIClient { $headers[] = "api_key: " . $this->apiKey; } - if (is_object($postData) or is_array($postData)) { + + if (strpos($headers['Content-Type'], "multipart/form-data") < 0 and (is_object($postData) or is_array($postData))) { $postData = json_encode($this->sanitizeForSerialization($postData)); } diff --git a/src/main/resources/php/api.mustache b/src/main/resources/php/api.mustache index 30d34f556e7..43ffbaa60a5 100644 --- a/src/main/resources/php/api.mustache +++ b/src/main/resources/php/api.mustache @@ -72,7 +72,12 @@ class {{classname}} { } {{#formParams}} if(${{paramName}} != null) { + {{#notFile}} $body['{{paramName}}'] = ${{paramName}}; + {{/notFile}} + {{#isFile}} + $body['{{paramName}}'] = '@' . ${{paramName}}; + {{/isFile}} } {{/formParams}} if (empty($body)) {