swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

[PHP] Separate `host` accessor into some parts

Open ackintosh opened this issue 8 years ago • 2 comments

PR checklist

  • [x] Read the contribution guidelines.
  • [x] Ran the shell 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). Windows batch files can be found in .\bin\windows\.
  • [x] Filed the PR against the correct branch: 3.0.0 branch for changes related to OpenAPI spec 3.0. Default: master.
  • [x] Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

https://github.com/swagger-api/swagger-codegen/issues/5841

Not only host but also scheme and basePath are managed by Configuration::setHost(), Configuration::getHost().

I think that it is better to match API definition key(scheme, host, basePath) and Configuration class interface(setXXX(), getXXX()) to prevent developers from getting confused.

  • Changed host accessor manages only host.
  • Added accessor for scheme basePath.
  • Added baseUrl().

ackintosh avatar Nov 23 '17 11:11 ackintosh

@jebentier @dkarlovi @mandrean @jfastnacht

ackintosh avatar Nov 24 '17 04:11 ackintosh

@ackintosh thanks for the PR. Ruby API client actually follows this approach but the majority of the generators use the current PHP approach.

I'm not sure which one is better for PHP developers but personally I feel comfortable with the current approach even though I worked on the Ruby generator more (I didn't come up with the current Ruby implementation. It was already implemented that way when I started working on this project)

wing328 avatar Jan 14 '18 15:01 wing328