diff --git a/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache index 8a030079fa0..e9e308cbf64 100644 --- a/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache @@ -31,6 +31,11 @@ class ApiClient { protected $defaultHeaders = array(); + /** + * The host (from basePath) + */ + protected $host = '{{basePath}}'; + /* * @var string timeout (second) of the HTTP request, by default set to 0, no timeout */ @@ -49,7 +54,11 @@ class ApiClient { /** * @param ApiConfiguration $config config for this ApiClient */ - function __construct(ApiConfiguration $config = null) { + function __construct($host = null, ApiConfiguration $config = null) { + if ($host != null) { + $this->host = $host; + } + if ($config == null) { $config = ApiConfiguration::getDefaultConfiguration(); } @@ -69,6 +78,7 @@ class ApiClient { } $this->defaultHeaders[$headerName] = $headerValue; + return $this; } /** @@ -80,6 +90,22 @@ class ApiClient { return $this->defaultHeaders; } + /** + * @param string $host + * @return ApiConfiguration + */ + public function setHost($host) { + $this->host = $host; + return $this; + } + + /** + * @return string + */ + public function getHost() { + return $this->host; + } + /** * delete the default header based on header name * @@ -99,6 +125,7 @@ class ApiClient { throw new \InvalidArgumentException('User-agent must be a string.'); $this->userAgent = $userAgent; + return $this; } /** @@ -120,6 +147,7 @@ class ApiClient { throw new \InvalidArgumentException('Timeout value must be numeric and a non-negative number.'); $this->curlTimeout = $seconds; + return $this; } /** diff --git a/modules/swagger-codegen/src/main/resources/php/ApiConfiguration.mustache b/modules/swagger-codegen/src/main/resources/php/ApiConfiguration.mustache index 1f0ebb496ab..764e0eafe89 100644 --- a/modules/swagger-codegen/src/main/resources/php/ApiConfiguration.mustache +++ b/modules/swagger-codegen/src/main/resources/php/ApiConfiguration.mustache @@ -21,11 +21,6 @@ class ApiConfiguration { private static $defaultConfiguration = null; - /** - * The host (from basePath) - */ - protected $host = '{{basePath}}'; - /** * Associate array to store API key(s) */ @@ -56,22 +51,6 @@ class ApiConfiguration { */ protected $debugFile = 'php://output'; - /** - * @param string $host - * @return ApiConfiguration - */ - public function setHost($host) { - $this->host = $host; - return $this; - } - - /** - * @return string - */ - public function getHost() { - return $this->host; - } - /** * @param string $key * @param string $value