mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-07 02:56:09 +00:00
Merge pull request #659 from wing328/add_php_unit_test
Bug fix for PHP client POST (model) and add more PHP test cases
This commit is contained in:
@@ -94,7 +94,11 @@ class APIClient {
|
||||
$headers[] = $this->headerName . ": " . $this->headerValue;
|
||||
}
|
||||
|
||||
if ((isset($headerName['Content-Type']) and strpos($headerName['Content-Type'], "multipart/form-data") === FALSE) and (is_object($postData) or is_array($postData))) {
|
||||
// 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
|
||||
$postData = json_encode($this->sanitizeForSerialization($postData));
|
||||
}
|
||||
|
||||
|
||||
@@ -87,11 +87,9 @@ class {{classname}} {
|
||||
// for model (json/xml)
|
||||
if (isset($_tempBody)) {
|
||||
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
|
||||
}
|
||||
|
||||
// for HTTP post (form)
|
||||
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") !== FALSE) {
|
||||
$httpBody = http_build_query($formParams);
|
||||
} else if (count($formParams) > 0) {
|
||||
// for HTTP post (form)
|
||||
$httpBody = $formParams;
|
||||
}
|
||||
|
||||
// make the API Call
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
<?php
|
||||
// source code generated by http://restunited.com
|
||||
// for any feedback/issue, please send to feedback{at}restunited.com
|
||||
|
||||
// load models defined for endpoints
|
||||
foreach (glob(dirname(__FILE__)."/lib/models/*.php") as $filename)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user