We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When using a parameter of name "body", the PHP generator nullifies it.
This is caused by variable name collision in the default PHP mustache template.
This Swagger 2.0 schema snippet will repro the bug:
{ ... "parameters": [ { "in": "body", "name": "body", "description": "Body object", "required": true, "schema": { "$ref": "#/definitions/Body" } } ... }
Resulting generated code:
public function createBody($body) { // parse inputs $resourcePath = "/bodies"; $resourcePath = str_replace("{format}", "json", $resourcePath); $method = "POST"; $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); $_header_accept = 'application/json'; if ($_header_accept !== '') { $headerParams['Accept'] = $_header_accept; } $_header_content_type = array('application/json',); $headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json'; // body params $body = null; if (isset($body)) { $body = $body; } // for model (json/xml) if (isset($body)) { $httpBody = $body; // $body is the method argument, if present } // for HTTP post (form) if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { $httpBody = http_build_query($formParams); } // make the API Call $response = $this->apiClient->callAPI($resourcePath, $method, $queryParams, $httpBody, $headerParams); if(! $response) { return null; } $responseObject = $this->apiClient->deserialize($response, 'Body'); return $responseObject; }
As you can see, $body = null will wipe out the passed-in value.
The text was updated successfully, but these errors were encountered:
Closing this, as it's fixed now.
Sorry, something went wrong.
No branches or pull requests
When using a parameter of name "body", the PHP generator nullifies it.
This is caused by variable name collision in the default PHP mustache template.
This Swagger 2.0 schema snippet will repro the bug:
Resulting generated code:
As you can see, $body = null will wipe out the passed-in value.
The text was updated successfully, but these errors were encountered: