Skip to content

Conversation

@philip
Copy link

@philip philip commented Jan 11, 2017

  • If host is defined/configured at runtime, then set host to the value set
    at runtime, otherwise use the default
  • Currently the runtime value is ignored unless you do something like
    the following (instantiate the api client, empty or otherwise):
    $api_client = new Swagger\Client\ApiClient();
    $foo = new Swagger\Client\Api\Bar($api_client);
    But now all you need is:
    $foo = new Swagger\Client\Api\Bar();
  • This use case is common if host is not defined in the swagger file
  • This now allows the host to be set at runtime under any condition,
    for example using either:
    • lib/Configuration.php $host
    • Swagger\Client\Configuration::getDefaultConfiguration()->setHost($host)
  • This could change behavior for some, as it means the configured host
    is used instead of the default, unless api client is instantiated first.
    Not sure why someone would do that, likely by accident.
  • This resolves [PHP] lib/Api constructors ignore configuration and set host to localhost  #4518

PR checklist

  • Read the contribution guildelines.
  • Ran the shell/batch script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates)
  • Filed the PR against the correct branch: master for non-breaking changes and 2.3.0 branch for breaking (non-backward compatible) changes.

Description of the PR

(details of the change, additional tests that have been done, reference to the issue for tracking, etc)

  value set at runtime, otherwise use the default
* Currently the runtime value is ignored unless you do something like
  the following (instantiate the api client, empty or otherwise):
    $api_client = new Swagger\Client\ApiClient();
    $foo = new Swagger\Client\Api\Bar($api_client);
  But now all you need is:
    $foo = new Swagger\Client\Api\Bar();
* This use case is common if host is not defined in the swagger file
* This now allows the host to be set at runtime under any condition,
  for example using either:
  * lib/Configuration.php $host
  * Swagger\Client\Configuration::getDefaultConfiguration()->setHost($host)
* This could change behavior for some, as it means the configured host
is used instead of the default, unless api client is instantiated first.
Not sure why someone would do that, likely by accident.
* This resolves swagger-api#4518
This contains unrelated changes, perhaps a different commit forgot to commit
these changes? I'm including those, too.
@philip
Copy link
Author

philip commented Jan 12, 2017

This was fixed in PR #4525 so closing this PR now.

@philip philip closed this Jan 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PHP] lib/Api constructors ignore configuration and set host to localhost

2 participants