Skip to content

Commit 0f041da

Browse files
committed
MultipartForm: adding support for php
1 parent 6c97a9c commit 0f041da

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/main/resources/php/Swagger.mustache

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ class APIClient {
7777
$headers[] = "api_key: " . $this->apiKey;
7878
}
7979

80-
if (is_object($postData) or is_array($postData)) {
80+
81+
if (strpos($headers['Content-Type'], "multipart/form-data") < 0 and (is_object($postData) or is_array($postData))) {
8182
$postData = json_encode($this->sanitizeForSerialization($postData));
8283
}
8384

src/main/resources/php/api.mustache

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ class {{classname}} {
7272
}
7373
{{#formParams}}
7474
if(${{paramName}} != null) {
75+
{{#notFile}}
7576
$body['{{paramName}}'] = ${{paramName}};
77+
{{/notFile}}
78+
{{#isFile}}
79+
$body['{{paramName}}'] = '@' . ${{paramName}};
80+
{{/isFile}}
7681
}
7782
{{/formParams}}
7883
if (empty($body)) {

0 commit comments

Comments
 (0)