From e0ed6719a055d9db22e259ad6b5c270fd2c41578 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sun, 10 Feb 2019 07:27:41 +0800 Subject: [PATCH] Add "servers" support to the operation, path in PHP API client (#2072) * add servers support to path, operation in php client * remove servers from spec * update based on feedback --- .../src/main/resources/php/api.mustache | 91 ++++++++++++++++++- .../lib/Api/AnotherFakeApi.php | 30 +++++- .../php/OpenAPIClient-php/lib/Api/FakeApi.php | 36 +++++++- .../lib/Api/FakeClassnameTags123Api.php | 30 +++++- .../php/OpenAPIClient-php/lib/Api/PetApi.php | 30 +++++- .../OpenAPIClient-php/lib/Api/StoreApi.php | 30 +++++- .../php/OpenAPIClient-php/lib/Api/UserApi.php | 30 +++++- .../lib/Api/AnotherFakeApi.php | 30 +++++- .../OpenAPIClient-php/lib/Api/DefaultApi.php | 30 +++++- .../php/OpenAPIClient-php/lib/Api/FakeApi.php | 36 +++++++- .../lib/Api/FakeClassnameTags123Api.php | 30 +++++- .../php/OpenAPIClient-php/lib/Api/PetApi.php | 30 +++++- .../OpenAPIClient-php/lib/Api/StoreApi.php | 30 +++++- .../php/OpenAPIClient-php/lib/Api/UserApi.php | 30 +++++- 14 files changed, 469 insertions(+), 24 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/php/api.mustache b/modules/openapi-generator/src/main/resources/php/api.mustache index 72e7ccd723b2..7a9ee0114b14 100644 --- a/modules/openapi-generator/src/main/resources/php/api.mustache +++ b/modules/openapi-generator/src/main/resources/php/api.mustache @@ -54,19 +54,47 @@ use {{invokerPackage}}\ObjectSerializer; */ protected $headerSelector; + /** + * @var int Host index + */ + protected $hostIndex; + /** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector + * @param int $host_index (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( ClientInterface $client = null, Configuration $config = null, - HeaderSelector $selector = null + HeaderSelector $selector = null, + $host_index = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $host_index; + } + + /** + * Set the host index + * + * @param int Host index (required) + */ + public function setHostIndex($host_index) + { + $this->hostIndex = $host_index; + } + + /** + * Get the host index + * + * @return Host index + */ + public function getHostIndex() + { + return $this->hostIndex; } /** @@ -93,6 +121,15 @@ use {{invokerPackage}}\ObjectSerializer; * Note: the input parameter is an associative array with the keys listed as the parameter name below * {{/vendorExtensions.x-group-parameters}} +{{#servers}} +{{#-first}} + * This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. +{{/-first}} + * URL: {{{url}}} +{{#-last}} + * +{{/-last}} +{{/servers}} {{#allParams}} * @param {{dataType}} ${{paramName}}{{#description}} {{description}}{{/description}}{{^description}} {{paramName}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} {{/allParams}} @@ -119,9 +156,18 @@ use {{invokerPackage}}\ObjectSerializer; * {{/description}} {{#vendorExtensions.x-group-parameters}} - * Note: the inpput parameter is an associative array with the keys listed as the parameter name below + * Note: the input parameter is an associative array with the keys listed as the parameter name below * {{/vendorExtensions.x-group-parameters}} +{{#servers}} +{{#-first}} + * This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. +{{/-first}} + * URL: {{{url}}} +{{#-last}} + * +{{/-last}} +{{/servers}} {{#allParams}} * @param {{dataType}} ${{paramName}}{{#description}} {{description}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} {{/allParams}} @@ -235,9 +281,18 @@ use {{invokerPackage}}\ObjectSerializer; * {{/description}} {{#vendorExtensions.x-group-parameters}} - * Note: the inpput parameter is an associative array with the keys listed as the parameter name below + * Note: the input parameter is an associative array with the keys listed as the parameter name below * {{/vendorExtensions.x-group-parameters}} +{{#servers}} +{{#-first}} + * This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. +{{/-first}} + * URL: {{{url}}} +{{#-last}} + * +{{/-last}} +{{/servers}} {{#allParams}} * @param {{dataType}} ${{paramName}}{{#description}} {{description}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} {{/allParams}} @@ -265,9 +320,18 @@ use {{invokerPackage}}\ObjectSerializer; * {{/description}} {{#vendorExtensions.x-group-parameters}} - * Note: the inpput parameter is an associative array with the keys listed as the parameter name below + * Note: the input parameter is an associative array with the keys listed as the parameter name below * {{/vendorExtensions.x-group-parameters}} +{{#servers}} +{{#-first}} + * This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. +{{/-first}} + * URL: {{{url}}} +{{#-last}} + * +{{/-last}} +{{/servers}} {{#allParams}} * @param {{dataType}} ${{paramName}}{{#description}} {{description}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} {{/allParams}} @@ -326,6 +390,15 @@ use {{invokerPackage}}\ObjectSerializer; * Note: the input parameter is an associative array with the keys listed as the parameter name below * {{/vendorExtensions.x-group-parameters}} +{{#servers}} +{{#-first}} + * This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. +{{/-first}} + * URL: {{{url}}} +{{#-last}} + * +{{/-last}} +{{/servers}} {{#allParams}} * @param {{dataType}} ${{paramName}}{{#description}} {{description}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} {{/allParams}} @@ -538,10 +611,18 @@ use {{invokerPackage}}\ObjectSerializer; $headers ); + {{#servers.0}} + $operationHosts = [{{#servers}}"{{{url}}}"{{^-last}}, {{/-last}}{{/servers}}]; + if ($this->hostIndex < 0 || $this->hostIndex >= sizeof($operationHosts)) { + throw new \InvalidArgumentException("Invalid index {$this->hostIndex} when selecting the host. Must be less than ".sizeof($operationHosts)); + } + $operationHost = $operationHosts[$this->hostIndex]; + + {{/servers.0}} $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( '{{httpMethod}}', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + {{^servers.0}}$this->config->getHost(){{/servers.0}}{{#servers.0}}$operationHost{{/servers.0}} . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php index a5f0b663f1a9..9e3a96b58863 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php @@ -64,19 +64,47 @@ class AnotherFakeApi */ protected $headerSelector; + /** + * @var int Host index + */ + protected $hostIndex; + /** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector + * @param int $host_index (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( ClientInterface $client = null, Configuration $config = null, - HeaderSelector $selector = null + HeaderSelector $selector = null, + $host_index = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $host_index; + } + + /** + * Set the host index + * + * @param int Host index (required) + */ + public function setHostIndex($host_index) + { + $this->hostIndex = $host_index; + } + + /** + * Get the host index + * + * @return Host index + */ + public function getHostIndex() + { + return $this->hostIndex; } /** diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php index c618ab9350bd..7e33b9d328ee 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php @@ -64,19 +64,47 @@ class FakeApi */ protected $headerSelector; + /** + * @var int Host index + */ + protected $hostIndex; + /** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector + * @param int $host_index (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( ClientInterface $client = null, Configuration $config = null, - HeaderSelector $selector = null + HeaderSelector $selector = null, + $host_index = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $host_index; + } + + /** + * Set the host index + * + * @param int Host index (required) + */ + public function setHostIndex($host_index) + { + $this->hostIndex = $host_index; + } + + /** + * Get the host index + * + * @return Host index + */ + public function getHostIndex() + { + return $this->hostIndex; } /** @@ -2764,7 +2792,7 @@ public function testGroupParameters($associative_array) * * Fake endpoint to test group parameters (optional) * - * Note: the inpput parameter is an associative array with the keys listed as the parameter name below + * Note: the input parameter is an associative array with the keys listed as the parameter name below * * @param int $required_string_group Required String in group parameters (required) * @param bool $required_boolean_group Required Boolean in group parameters (required) @@ -2823,7 +2851,7 @@ public function testGroupParametersWithHttpInfo($associative_array) * * Fake endpoint to test group parameters (optional) * - * Note: the inpput parameter is an associative array with the keys listed as the parameter name below + * Note: the input parameter is an associative array with the keys listed as the parameter name below * * @param int $required_string_group Required String in group parameters (required) * @param bool $required_boolean_group Required Boolean in group parameters (required) @@ -2850,7 +2878,7 @@ function ($response) { * * Fake endpoint to test group parameters (optional) * - * Note: the inpput parameter is an associative array with the keys listed as the parameter name below + * Note: the input parameter is an associative array with the keys listed as the parameter name below * * @param int $required_string_group Required String in group parameters (required) * @param bool $required_boolean_group Required Boolean in group parameters (required) diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php index 2968d306fb47..83020131032d 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php @@ -64,19 +64,47 @@ class FakeClassnameTags123Api */ protected $headerSelector; + /** + * @var int Host index + */ + protected $hostIndex; + /** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector + * @param int $host_index (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( ClientInterface $client = null, Configuration $config = null, - HeaderSelector $selector = null + HeaderSelector $selector = null, + $host_index = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $host_index; + } + + /** + * Set the host index + * + * @param int Host index (required) + */ + public function setHostIndex($host_index) + { + $this->hostIndex = $host_index; + } + + /** + * Get the host index + * + * @return Host index + */ + public function getHostIndex() + { + return $this->hostIndex; } /** diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php index 12ed0ecc4f85..e47f9affced1 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php @@ -64,19 +64,47 @@ class PetApi */ protected $headerSelector; + /** + * @var int Host index + */ + protected $hostIndex; + /** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector + * @param int $host_index (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( ClientInterface $client = null, Configuration $config = null, - HeaderSelector $selector = null + HeaderSelector $selector = null, + $host_index = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $host_index; + } + + /** + * Set the host index + * + * @param int Host index (required) + */ + public function setHostIndex($host_index) + { + $this->hostIndex = $host_index; + } + + /** + * Get the host index + * + * @return Host index + */ + public function getHostIndex() + { + return $this->hostIndex; } /** diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php index 9cd2dbc0ecd2..d96ad7917f0f 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php @@ -64,19 +64,47 @@ class StoreApi */ protected $headerSelector; + /** + * @var int Host index + */ + protected $hostIndex; + /** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector + * @param int $host_index (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( ClientInterface $client = null, Configuration $config = null, - HeaderSelector $selector = null + HeaderSelector $selector = null, + $host_index = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $host_index; + } + + /** + * Set the host index + * + * @param int Host index (required) + */ + public function setHostIndex($host_index) + { + $this->hostIndex = $host_index; + } + + /** + * Get the host index + * + * @return Host index + */ + public function getHostIndex() + { + return $this->hostIndex; } /** diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php index 6cfda7b3ee0b..a70e41893f79 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php @@ -64,19 +64,47 @@ class UserApi */ protected $headerSelector; + /** + * @var int Host index + */ + protected $hostIndex; + /** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector + * @param int $host_index (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( ClientInterface $client = null, Configuration $config = null, - HeaderSelector $selector = null + HeaderSelector $selector = null, + $host_index = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $host_index; + } + + /** + * Set the host index + * + * @param int Host index (required) + */ + public function setHostIndex($host_index) + { + $this->hostIndex = $host_index; + } + + /** + * Get the host index + * + * @return Host index + */ + public function getHostIndex() + { + return $this->hostIndex; } /** diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php index 62319b800696..e2d671eaea2a 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php @@ -64,19 +64,47 @@ class AnotherFakeApi */ protected $headerSelector; + /** + * @var int Host index + */ + protected $hostIndex; + /** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector + * @param int $host_index (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( ClientInterface $client = null, Configuration $config = null, - HeaderSelector $selector = null + HeaderSelector $selector = null, + $host_index = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $host_index; + } + + /** + * Set the host index + * + * @param int Host index (required) + */ + public function setHostIndex($host_index) + { + $this->hostIndex = $host_index; + } + + /** + * Get the host index + * + * @return Host index + */ + public function getHostIndex() + { + return $this->hostIndex; } /** diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/DefaultApi.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/DefaultApi.php index 96f465d3cb12..b1ad7e973683 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/DefaultApi.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/DefaultApi.php @@ -64,19 +64,47 @@ class DefaultApi */ protected $headerSelector; + /** + * @var int Host index + */ + protected $hostIndex; + /** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector + * @param int $host_index (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( ClientInterface $client = null, Configuration $config = null, - HeaderSelector $selector = null + HeaderSelector $selector = null, + $host_index = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $host_index; + } + + /** + * Set the host index + * + * @param int Host index (required) + */ + public function setHostIndex($host_index) + { + $this->hostIndex = $host_index; + } + + /** + * Get the host index + * + * @return Host index + */ + public function getHostIndex() + { + return $this->hostIndex; } /** diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php index 5e86d0aeed09..817496d4b1ef 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php @@ -64,19 +64,47 @@ class FakeApi */ protected $headerSelector; + /** + * @var int Host index + */ + protected $hostIndex; + /** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector + * @param int $host_index (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( ClientInterface $client = null, Configuration $config = null, - HeaderSelector $selector = null + HeaderSelector $selector = null, + $host_index = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $host_index; + } + + /** + * Set the host index + * + * @param int Host index (required) + */ + public function setHostIndex($host_index) + { + $this->hostIndex = $host_index; + } + + /** + * Get the host index + * + * @return Host index + */ + public function getHostIndex() + { + return $this->hostIndex; } /** @@ -2545,7 +2573,7 @@ public function testGroupParameters($associative_array) * * Fake endpoint to test group parameters (optional) * - * Note: the inpput parameter is an associative array with the keys listed as the parameter name below + * Note: the input parameter is an associative array with the keys listed as the parameter name below * * @param int $required_string_group Required String in group parameters (required) * @param bool $required_boolean_group Required Boolean in group parameters (required) @@ -2604,7 +2632,7 @@ public function testGroupParametersWithHttpInfo($associative_array) * * Fake endpoint to test group parameters (optional) * - * Note: the inpput parameter is an associative array with the keys listed as the parameter name below + * Note: the input parameter is an associative array with the keys listed as the parameter name below * * @param int $required_string_group Required String in group parameters (required) * @param bool $required_boolean_group Required Boolean in group parameters (required) @@ -2631,7 +2659,7 @@ function ($response) { * * Fake endpoint to test group parameters (optional) * - * Note: the inpput parameter is an associative array with the keys listed as the parameter name below + * Note: the input parameter is an associative array with the keys listed as the parameter name below * * @param int $required_string_group Required String in group parameters (required) * @param bool $required_boolean_group Required Boolean in group parameters (required) diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php index 44eb33aa4e6c..458880cde32e 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php @@ -64,19 +64,47 @@ class FakeClassnameTags123Api */ protected $headerSelector; + /** + * @var int Host index + */ + protected $hostIndex; + /** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector + * @param int $host_index (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( ClientInterface $client = null, Configuration $config = null, - HeaderSelector $selector = null + HeaderSelector $selector = null, + $host_index = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $host_index; + } + + /** + * Set the host index + * + * @param int Host index (required) + */ + public function setHostIndex($host_index) + { + $this->hostIndex = $host_index; + } + + /** + * Get the host index + * + * @return Host index + */ + public function getHostIndex() + { + return $this->hostIndex; } /** diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php index 98e126ae2ef6..e8992f737f01 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php @@ -64,19 +64,47 @@ class PetApi */ protected $headerSelector; + /** + * @var int Host index + */ + protected $hostIndex; + /** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector + * @param int $host_index (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( ClientInterface $client = null, Configuration $config = null, - HeaderSelector $selector = null + HeaderSelector $selector = null, + $host_index = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $host_index; + } + + /** + * Set the host index + * + * @param int Host index (required) + */ + public function setHostIndex($host_index) + { + $this->hostIndex = $host_index; + } + + /** + * Get the host index + * + * @return Host index + */ + public function getHostIndex() + { + return $this->hostIndex; } /** diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php index fd69b038f85c..59c726a1f854 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php @@ -64,19 +64,47 @@ class StoreApi */ protected $headerSelector; + /** + * @var int Host index + */ + protected $hostIndex; + /** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector + * @param int $host_index (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( ClientInterface $client = null, Configuration $config = null, - HeaderSelector $selector = null + HeaderSelector $selector = null, + $host_index = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $host_index; + } + + /** + * Set the host index + * + * @param int Host index (required) + */ + public function setHostIndex($host_index) + { + $this->hostIndex = $host_index; + } + + /** + * Get the host index + * + * @return Host index + */ + public function getHostIndex() + { + return $this->hostIndex; } /** diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php index 18f715479793..9dba7141d020 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php @@ -64,19 +64,47 @@ class UserApi */ protected $headerSelector; + /** + * @var int Host index + */ + protected $hostIndex; + /** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector + * @param int $host_index (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( ClientInterface $client = null, Configuration $config = null, - HeaderSelector $selector = null + HeaderSelector $selector = null, + $host_index = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $host_index; + } + + /** + * Set the host index + * + * @param int Host index (required) + */ + public function setHostIndex($host_index) + { + $this->hostIndex = $host_index; + } + + /** + * Get the host index + * + * @return Host index + */ + public function getHostIndex() + { + return $this->hostIndex; } /**