Skip to content

Commit

Permalink
fix for #224, added safe php comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
fehguy committed Feb 17, 2015
1 parent 39b2bf4 commit fde5014
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 deletions.
8 changes: 4 additions & 4 deletions modules/swagger-codegen/src/main/resources/php/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,20 @@ class {{classname}} {
$headerParams['Content-Type'] = '{{#consumes}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/consumes}}';
{{#queryParams}}// query params
if(${{paramName}} != null) {
if(${{paramName}} !== null) {
$queryParams['{{paramName}}'] = $this->apiClient->toQueryValue(${{paramName}});
}{{/queryParams}}
{{#headerParams}}// header params
if(${{paramName}} != null) {
if(${{paramName}} !== null) {
$headerParams['{{paramName}}'] = $this->apiClient->toHeaderValue(${{paramName}});
}{{/headerParams}}
{{#pathParams}}// path params
if(${{paramName}} != null) {
if(${{paramName}} !== null) {
$resourcePath = str_replace("{" . "{{paramName}}" . "}",
$this->apiClient->toPathValue(${{paramName}}), $resourcePath);
}{{/pathParams}}
{{#formParams}}
if (${{paramName}} != null) {
if (${{paramName}} !== null) {
$formParams[{{paramName}}] = {{#isFile}}'@' . {{/isFile}}${{paramName}};
}{{/formParams}}
{{#bodyParams}}// body params
Expand Down
31 changes: 18 additions & 13 deletions samples/client/petstore/php/PetApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function findPetsByStatus($status) {
$headerParams['Content-Type'] = '';

// query params
if($status != null) {
if($status !== null) {
$queryParams['status'] = $this->apiClient->toQueryValue($status);
}

Expand Down Expand Up @@ -188,7 +188,7 @@ public function findPetsByTags($tags) {
$headerParams['Content-Type'] = '';

// query params
if($tags != null) {
if($tags !== null) {
$queryParams['tags'] = $this->apiClient->toQueryValue($tags);
}

Expand Down Expand Up @@ -240,7 +240,7 @@ public function getPetById($petId) {


// path params
if($petId != null) {
if($petId !== null) {
$resourcePath = str_replace("{" . "petId" . "}",
$this->apiClient->toPathValue($petId), $resourcePath);
}
Expand Down Expand Up @@ -293,15 +293,15 @@ public function updatePetWithForm($petId, $name, $status) {


// path params
if($petId != null) {
if($petId !== null) {
$resourcePath = str_replace("{" . "petId" . "}",
$this->apiClient->toPathValue($petId), $resourcePath);
}

if ($name != null) {
if ($name !== null) {
$formParams[name] = $name;
}
if ($status != null) {
if ($status !== null) {
$formParams[status] = $status;
}

Expand Down Expand Up @@ -344,11 +344,11 @@ public function deletePet($api_key, $petId) {


// header params
if($api_key != null) {
if($api_key !== null) {
$headerParams['api_key'] = $this->apiClient->toHeaderValue($api_key);
}
// path params
if($petId != null) {
if($petId !== null) {
$resourcePath = str_replace("{" . "petId" . "}",
$this->apiClient->toPathValue($petId), $resourcePath);
}
Expand All @@ -373,13 +373,14 @@ public function deletePet($api_key, $petId) {
* uploadFile
*
* uploads an image
* additionalMetadata, string: Additional data to pass to server (required)
* petId, int: ID of pet to update (required)
* * additionalMetadata, string: Additional data to pass to server (required)
* * file, file: file to upload (required)
*
* @return
*/

public function uploadFile($additionalMetadata, $file) {
public function uploadFile($petId, $additionalMetadata, $file) {

// parse inputs
$resourcePath = "/pet/{petId}/uploadImage";
Expand All @@ -393,12 +394,16 @@ public function uploadFile($additionalMetadata, $file) {



// path params
if($petId !== null) {
$resourcePath = str_replace("{" . "petId" . "}",
$this->apiClient->toPathValue($petId), $resourcePath);
}


if ($additionalMetadata != null) {
if ($additionalMetadata !== null) {
$formParams[additionalMetadata] = $additionalMetadata;
}
if ($file != null) {
if ($file !== null) {
$formParams[file] = '@' . $file;
}

Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/php/StoreApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function getOrderById($orderId) {


// path params
if($orderId != null) {
if($orderId !== null) {
$resourcePath = str_replace("{" . "orderId" . "}",
$this->apiClient->toPathValue($orderId), $resourcePath);
}
Expand Down Expand Up @@ -198,7 +198,7 @@ public function deleteOrder($orderId) {


// path params
if($orderId != null) {
if($orderId !== null) {
$resourcePath = str_replace("{" . "orderId" . "}",
$this->apiClient->toPathValue($orderId), $resourcePath);
}
Expand Down
10 changes: 5 additions & 5 deletions samples/client/petstore/php/UserApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ public function loginUser($username, $password) {
$headerParams['Content-Type'] = '';

// query params
if($username != null) {
if($username !== null) {
$queryParams['username'] = $this->apiClient->toQueryValue($username);
}// query params
if($password != null) {
if($password !== null) {
$queryParams['password'] = $this->apiClient->toQueryValue($password);
}

Expand Down Expand Up @@ -279,7 +279,7 @@ public function getUserByName($username) {


// path params
if($username != null) {
if($username !== null) {
$resourcePath = str_replace("{" . "username" . "}",
$this->apiClient->toPathValue($username), $resourcePath);
}
Expand Down Expand Up @@ -331,7 +331,7 @@ public function updateUser($username, $body) {


// path params
if($username != null) {
if($username !== null) {
$resourcePath = str_replace("{" . "username" . "}",
$this->apiClient->toPathValue($username), $resourcePath);
}
Expand Down Expand Up @@ -380,7 +380,7 @@ public function deleteUser($username) {


// path params
if($username != null) {
if($username !== null) {
$resourcePath = str_replace("{" . "username" . "}",
$this->apiClient->toPathValue($username), $resourcePath);
}
Expand Down

0 comments on commit fde5014

Please sign in to comment.