Merge pull request #487 from wing328/update_php_form

form parameter(single quote), add more comments
This commit is contained in:
Tony Tam 2015-03-11 08:44:26 -07:00
commit 0a949e26f0
5 changed files with 34 additions and 10 deletions

View File

@ -61,9 +61,9 @@ class {{classname}} {
$resourcePath = str_replace("{" . "{{baseName}}" . "}", $resourcePath = str_replace("{" . "{{baseName}}" . "}",
$this->apiClient->toPathValue(${{paramName}}), $resourcePath); $this->apiClient->toPathValue(${{paramName}}), $resourcePath);
}{{/pathParams}} }{{/pathParams}}
{{#formParams}} {{#formParams}}// form params
if (${{paramName}} !== null) { if (${{paramName}} !== null) {
$formParams[{{baseName}}] = {{#isFile}}'@' . {{/isFile}}${{paramName}}; $formParams['{{baseName}}'] = {{#isFile}}'@' . {{/isFile}}${{paramName}};
}{{/formParams}} }{{/formParams}}
{{#bodyParams}}// body params {{#bodyParams}}// body params
$body = null; $body = null;
@ -71,6 +71,7 @@ class {{classname}} {
$body = ${{paramName}}; $body = ${{paramName}};
}{{/bodyParams}} }{{/bodyParams}}
// for HTTP post (form)
$body = $body ?: $formParams; $body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {

View File

@ -57,6 +57,7 @@ class PetApi {
$body = $body; $body = $body;
} }
// for HTTP post (form)
$body = $body ?: $formParams; $body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
@ -102,6 +103,7 @@ class PetApi {
$body = $body; $body = $body;
} }
// for HTTP post (form)
$body = $body ?: $formParams; $body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
@ -146,6 +148,7 @@ class PetApi {
// for HTTP post (form)
$body = $body ?: $formParams; $body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
@ -196,6 +199,7 @@ class PetApi {
// for HTTP post (form)
$body = $body ?: $formParams; $body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
@ -247,6 +251,7 @@ class PetApi {
// for HTTP post (form)
$body = $body ?: $formParams; $body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
@ -297,15 +302,16 @@ class PetApi {
$resourcePath = str_replace("{" . "petId" . "}", $resourcePath = str_replace("{" . "petId" . "}",
$this->apiClient->toPathValue($petId), $resourcePath); $this->apiClient->toPathValue($petId), $resourcePath);
} }
// form params
if ($name !== null) { if ($name !== null) {
$formParams[name] = $name; $formParams['name'] = $name;
} }// form params
if ($status !== null) { if ($status !== null) {
$formParams[status] = $status; $formParams['status'] = $status;
} }
// for HTTP post (form)
$body = $body ?: $formParams; $body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
@ -355,6 +361,7 @@ class PetApi {
// for HTTP post (form)
$body = $body ?: $formParams; $body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
@ -399,15 +406,16 @@ class PetApi {
$resourcePath = str_replace("{" . "petId" . "}", $resourcePath = str_replace("{" . "petId" . "}",
$this->apiClient->toPathValue($petId), $resourcePath); $this->apiClient->toPathValue($petId), $resourcePath);
} }
// form params
if ($additionalMetadata !== null) { if ($additionalMetadata !== null) {
$formParams[additionalMetadata] = $additionalMetadata; $formParams['additionalMetadata'] = $additionalMetadata;
} }// form params
if ($file !== null) { if ($file !== null) {
$formParams[file] = '@' . $file; $formParams['file'] = '@' . $file;
} }
// for HTTP post (form)
$body = $body ?: $formParams; $body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {

View File

@ -52,6 +52,7 @@ class StoreApi {
// for HTTP post (form)
$body = $body ?: $formParams; $body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
@ -103,6 +104,7 @@ class StoreApi {
$body = $body; $body = $body;
} }
// for HTTP post (form)
$body = $body ?: $formParams; $body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
@ -154,6 +156,7 @@ class StoreApi {
// for HTTP post (form)
$body = $body ?: $formParams; $body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
@ -205,6 +208,7 @@ class StoreApi {
// for HTTP post (form)
$body = $body ?: $formParams; $body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {

View File

@ -107,6 +107,9 @@ class APIClient {
if ($method == self::$POST) { if ($method == self::$POST) {
curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
} else if ($method == self::$PATCH) {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH");
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
} else if ($method == self::$PUT) { } else if ($method == self::$PUT) {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);

View File

@ -57,6 +57,7 @@ class UserApi {
$body = $body; $body = $body;
} }
// for HTTP post (form)
$body = $body ?: $formParams; $body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
@ -102,6 +103,7 @@ class UserApi {
$body = $body; $body = $body;
} }
// for HTTP post (form)
$body = $body ?: $formParams; $body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
@ -147,6 +149,7 @@ class UserApi {
$body = $body; $body = $body;
} }
// for HTTP post (form)
$body = $body ?: $formParams; $body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
@ -195,6 +198,7 @@ class UserApi {
// for HTTP post (form)
$body = $body ?: $formParams; $body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
@ -241,6 +245,7 @@ class UserApi {
// for HTTP post (form)
$body = $body ?: $formParams; $body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
@ -286,6 +291,7 @@ class UserApi {
// for HTTP post (form)
$body = $body ?: $formParams; $body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
@ -342,6 +348,7 @@ class UserApi {
$body = $body; $body = $body;
} }
// for HTTP post (form)
$body = $body ?: $formParams; $body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
@ -387,6 +394,7 @@ class UserApi {
// for HTTP post (form)
$body = $body ?: $formParams; $body = $body ?: $formParams;
if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {