[PHP] API classes override default config unnecessarily
Description
PHP Base API classes call setPath() on the ApiServer by default. Here's a sample generated constructor:
public function __construct(\SwaggerUserService\ApiClient $apiClient = null)
{
if ($apiClient == null) {
$apiClient = new ApiClient();
$apiClient->getConfig()->setHost('http://localhost/v1');
}
$this->apiClient = $apiClient;
}
Calling setHost() is unnecessary because ApiClient() constructor configures itself based on the default. A related issue is that the code assumes (and hardcodes) localhost as the host when one isn't provided.
This combination makes wrapping the Swagger-generated client in our host-discovery code unnecessarily complex.
Swagger-codegen version
Unsure what version is being used, not sure where to find that. I installed codegen through Homebrew. Looking at the code in master, though, this appears to be an issue there as well.
Swagger declaration file content or url
https://gist.github.com/toomuchpete/38ad55e570e103954d404c5df73c0e00
Command line used for generation
swagger-codegen generate -l php -i swagger.yaml
Steps to reproduce
Related issues
None found.
Suggest a Fix
Remove this line: https://github.com/swagger-api/swagger-codegen/blob/1ea9865a4498e26bb1f4ecf490aaad19d19357a8/modules/swagger-codegen/src/main/resources/php/api.mustache#L52
@toomuchpete thanks for reporting the issue and your suggested fix looks good to me.
Please kindly file a PR so that we can review the change.
@wing328 -- I don't want to mess with the workflow for this issue, if one exists, but the fix for this issue has been merged in. Should this ticket be closed now?
@toomuchpete I just closed it. Thanks for the reminder.