From 302922b8a4c8f10f770792de88eacbdf2d52e205 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sun, 10 Feb 2019 12:41:38 +0800 Subject: [PATCH] update php oas3 samples --- .../php/OpenAPIClient-php/lib/Api/PetApi.php | 56 ++++++++++++++++++- 1 file changed, 54 insertions(+), 2 deletions(-) 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 e8992f737f01..9de9ca046c77 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 @@ -120,6 +120,10 @@ class PetApi * * Add a new pet to the store * + * This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * URL: http://petstore.swagger.io/v2 + * URL: http://path-server-test.petstore.local/v2 + * * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * * @throws \OpenAPI\Client\ApiException on non-2xx response @@ -136,6 +140,10 @@ class PetApi * * Add a new pet to the store * + * This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * URL: http://petstore.swagger.io/v2 + * URL: http://path-server-test.petstore.local/v2 + * * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * * @throws \OpenAPI\Client\ApiException on non-2xx response @@ -188,6 +196,10 @@ class PetApi * * Add a new pet to the store * + * This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * URL: http://petstore.swagger.io/v2 + * URL: http://path-server-test.petstore.local/v2 + * * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * * @throws \InvalidArgumentException @@ -208,6 +220,10 @@ class PetApi * * Add a new pet to the store * + * This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * URL: http://petstore.swagger.io/v2 + * URL: http://path-server-test.petstore.local/v2 + * * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * * @throws \InvalidArgumentException @@ -244,6 +260,10 @@ class PetApi /** * Create request for operation 'addPet' * + * This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * URL: http://petstore.swagger.io/v2 + * URL: http://path-server-test.petstore.local/v2 + * * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * * @throws \InvalidArgumentException @@ -329,10 +349,16 @@ class PetApi $headers ); + $operationHosts = ["http://petstore.swagger.io/v2", "http://path-server-test.petstore.local/v2"]; + 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]; + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'POST', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); @@ -1407,6 +1433,10 @@ class PetApi * * Update an existing pet * + * This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * URL: http://petstore.swagger.io/v2 + * URL: http://path-server-test.petstore.local/v2 + * * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * * @throws \OpenAPI\Client\ApiException on non-2xx response @@ -1423,6 +1453,10 @@ class PetApi * * Update an existing pet * + * This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * URL: http://petstore.swagger.io/v2 + * URL: http://path-server-test.petstore.local/v2 + * * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * * @throws \OpenAPI\Client\ApiException on non-2xx response @@ -1475,6 +1509,10 @@ class PetApi * * Update an existing pet * + * This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * URL: http://petstore.swagger.io/v2 + * URL: http://path-server-test.petstore.local/v2 + * * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * * @throws \InvalidArgumentException @@ -1495,6 +1533,10 @@ class PetApi * * Update an existing pet * + * This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * URL: http://petstore.swagger.io/v2 + * URL: http://path-server-test.petstore.local/v2 + * * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * * @throws \InvalidArgumentException @@ -1531,6 +1573,10 @@ class PetApi /** * Create request for operation 'updatePet' * + * This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * URL: http://petstore.swagger.io/v2 + * URL: http://path-server-test.petstore.local/v2 + * * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * * @throws \InvalidArgumentException @@ -1616,10 +1662,16 @@ class PetApi $headers ); + $operationHosts = ["http://petstore.swagger.io/v2", "http://path-server-test.petstore.local/v2"]; + 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]; + $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( 'PUT', - $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody );