From 0f041dae90af5898af55da5a1b25b3644bcc59ac Mon Sep 17 00:00:00 2001 From: James Ebentier Date: Wed, 4 Feb 2015 11:49:28 -0800 Subject: [PATCH] MultipartForm: adding support for php --- src/main/resources/php/Swagger.mustache | 3 ++- src/main/resources/php/api.mustache | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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)) {