From a483d7a854daee2986928b1df6f540d91c17d2d3 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 28 Jul 2025 17:53:55 +0800 Subject: [PATCH 01/10] test php clients in github workflow --- .github/workflows/samples-php-client.yaml | 45 +++++++++++++++++++ ...ith-fake-endpoints-models-for-testing.yaml | 1 + ...ith-fake-endpoints-models-for-testing.yaml | 1 + .../OpenAPIClient-php/docs/Api/PetApi.md | 6 ++- .../OpenAPIClient-php/src/Api/PetApi.php | 18 ++++++++ .../php/OpenAPIClient-php/docs/Api/PetApi.md | 6 ++- .../php/OpenAPIClient-php/lib/Api/PetApi.php | 18 ++++++++ .../petstore/php/psr-18/lib/Api/PetApi.php | 14 +++++- 8 files changed, 103 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/samples-php-client.yaml diff --git a/.github/workflows/samples-php-client.yaml b/.github/workflows/samples-php-client.yaml new file mode 100644 index 000000000000..df47d5fea0aa --- /dev/null +++ b/.github/workflows/samples-php-client.yaml @@ -0,0 +1,45 @@ +name: Samples PHP clients + +on: + push: + paths: + - samples/client/petstore/php/OpenAPIClient-php/** + pull_request: + paths: + - samples/client/petstore/php/OpenAPIClient-php/** +jobs: + build: + name: Build PHP projects + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: + - "8.1" + - "8.2" + - "8.3" + - "8.4" + sample: + # clients + - samples/client/petstore/php/OpenAPIClient-php/ + services: + petstore-api: + image: swaggerapi/petstore + ports: + - 80:8080 + env: + SWAGGER_HOST: http://petstore.swagger.io + SWAGGER_BASE_PATH: /v2 + steps: + - uses: actions/checkout@v4 + - name: Setup PHP with tools + uses: shivammathur/setup-php@v2 + with: + php-version: "${{ matrix.php }}" + tools: php-cs-fixer, phpunit + - name: composer install + working-directory: ${{ matrix.sample }} + run: composer install + - name: phpunit + working-directory: ${{ matrix.sample }} + run: vendor/bin/phpunit diff --git a/modules/openapi-generator/src/test/resources/3_0/php-nextgen/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/3_0/php-nextgen/petstore-with-fake-endpoints-models-for-testing.yaml index 5ab53cee08b1..bc56de575adb 100644 --- a/modules/openapi-generator/src/test/resources/3_0/php-nextgen/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/php-nextgen/petstore-with-fake-endpoints-models-for-testing.yaml @@ -31,6 +31,7 @@ paths: $ref: '#/components/schemas/Foo' /pet: servers: + - url: 'http://localhost/v2' - url: 'http://petstore.swagger.io/v2' - url: 'http://path-server-test.petstore.local/v2' - url: 'http://{server}.swagger.io:{port}/v2' diff --git a/modules/openapi-generator/src/test/resources/3_0/php/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/3_0/php/petstore-with-fake-endpoints-models-for-testing.yaml index c24a3993f617..eda138fdef93 100644 --- a/modules/openapi-generator/src/test/resources/3_0/php/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/php/petstore-with-fake-endpoints-models-for-testing.yaml @@ -31,6 +31,7 @@ paths: $ref: '#/components/schemas/Foo' /pet: servers: + - url: 'http://localhost/v2' - url: 'http://petstore.swagger.io/v2' - url: 'http://path-server-test.petstore.local/v2' - url: 'http://{server}.swagger.io:{port}/v2' diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Api/PetApi.md b/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Api/PetApi.md index 7cc169e98bb7..40edf90bfaaf 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Api/PetApi.md +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Api/PetApi.md @@ -21,7 +21,7 @@ All URIs are relative to http://petstore.swagger.io:80/v2, except if the operati addPet($pet) ``` ### URI(s): -- http://petstore.swagger.io/v2 - http://path-server-test.petstore.local/v2 - http://{server}.swagger.io:{port}/v2 test server with variables +- http://localhost/v2 - http://petstore.swagger.io/v2 - http://path-server-test.petstore.local/v2 - http://{server}.swagger.io:{port}/v2 test server with variables - Variables: - server: target server - Allowed values: @@ -80,6 +80,7 @@ try { + ### Return type void (empty response body) @@ -346,7 +347,7 @@ try { updatePet($pet) ``` ### URI(s): -- http://petstore.swagger.io/v2 - http://path-server-test.petstore.local/v2 - http://{server}.swagger.io:{port}/v2 test server with variables +- http://localhost/v2 - http://petstore.swagger.io/v2 - http://path-server-test.petstore.local/v2 - http://{server}.swagger.io:{port}/v2 test server with variables - Variables: - server: target server - Allowed values: @@ -405,6 +406,7 @@ try { + ### Return type void (empty response body) diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/PetApi.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/PetApi.php index 73d617d62908..af6503be584d 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/PetApi.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/PetApi.php @@ -158,6 +158,7 @@ public function getConfig(): Configuration * * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. * if needed, use the 'variables' parameter to pass variables to the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -198,6 +199,7 @@ public function addPet( * * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. * if needed, use the 'variables' parameter to pass variables to the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -269,6 +271,7 @@ public function addPetWithHttpInfo( * * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. * if needed, use the 'variables' parameter to pass variables to the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -313,6 +316,7 @@ function ($response) { * * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. * if needed, use the 'variables' parameter to pass variables to the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -373,6 +377,7 @@ function ($exception) { * * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. * if needed, use the 'variables' parameter to pass variables to the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -504,6 +509,10 @@ public function addPetRequest( protected function getHostSettingsForaddPet(): array { return [ + [ + "url" => "http://localhost/v2", + "description" => "No description provided", + ], [ "url" => "http://petstore.swagger.io/v2", "description" => "No description provided", @@ -1656,6 +1665,7 @@ public function getPetByIdRequest( * * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. * if needed, use the 'variables' parameter to pass variables to the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -1696,6 +1706,7 @@ public function updatePet( * * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. * if needed, use the 'variables' parameter to pass variables to the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -1767,6 +1778,7 @@ public function updatePetWithHttpInfo( * * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. * if needed, use the 'variables' parameter to pass variables to the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -1811,6 +1823,7 @@ function ($response) { * * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. * if needed, use the 'variables' parameter to pass variables to the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -1871,6 +1884,7 @@ function ($exception) { * * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. * if needed, use the 'variables' parameter to pass variables to the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -2002,6 +2016,10 @@ public function updatePetRequest( protected function getHostSettingsForupdatePet(): array { return [ + [ + "url" => "http://localhost/v2", + "description" => "No description provided", + ], [ "url" => "http://petstore.swagger.io/v2", "description" => "No description provided", diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Api/PetApi.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Api/PetApi.md index 7e0512051f17..1cef0c37d817 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/docs/Api/PetApi.md +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Api/PetApi.md @@ -23,7 +23,7 @@ All URIs are relative to http://petstore.swagger.io:80/v2, except if the operati addPet($pet) ``` ### URI(s): -- http://petstore.swagger.io/v2 - http://path-server-test.petstore.local/v2 - http://{server}.swagger.io:{port}/v2 test server with variables +- http://localhost/v2 - http://petstore.swagger.io/v2 - http://path-server-test.petstore.local/v2 - http://{server}.swagger.io:{port}/v2 test server with variables - Variables: - server: target server - Allowed values: @@ -82,6 +82,7 @@ try { + ### Return type void (empty response body) @@ -348,7 +349,7 @@ try { updatePet($pet) ``` ### URI(s): -- http://petstore.swagger.io/v2 - http://path-server-test.petstore.local/v2 - http://{server}.swagger.io:{port}/v2 test server with variables +- http://localhost/v2 - http://petstore.swagger.io/v2 - http://path-server-test.petstore.local/v2 - http://{server}.swagger.io:{port}/v2 test server with variables - Variables: - server: target server - Allowed values: @@ -407,6 +408,7 @@ try { + ### Return type void (empty response body) 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 4b4e48c63f9b..b856a8244825 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php @@ -164,6 +164,7 @@ public function getConfig() * * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. * if needed, use the 'variables' parameter to pass variables to the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -199,6 +200,7 @@ public function addPet($pet, ?int $hostIndex = null, array $variables = [], stri * * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. * if needed, use the 'variables' parameter to pass variables to the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -266,6 +268,7 @@ public function addPetWithHttpInfo($pet, ?int $hostIndex = null, array $variable * * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. * if needed, use the 'variables' parameter to pass variables to the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -305,6 +308,7 @@ function ($response) { * * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. * if needed, use the 'variables' parameter to pass variables to the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -360,6 +364,7 @@ function ($exception) { * * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. * if needed, use the 'variables' parameter to pass variables to the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -486,6 +491,10 @@ public function addPetRequest($pet, ?int $hostIndex = null, array $variables = [ protected function getHostSettingsForaddPet(): array { return [ + [ + "url" => "http://localhost/v2", + "description" => "No description provided", + ], [ "url" => "http://petstore.swagger.io/v2", "description" => "No description provided", @@ -1583,6 +1592,7 @@ public function getPetByIdRequest($pet_id, string $contentType = self::contentTy * * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. * if needed, use the 'variables' parameter to pass variables to the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -1618,6 +1628,7 @@ public function updatePet($pet, ?int $hostIndex = null, array $variables = [], s * * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. * if needed, use the 'variables' parameter to pass variables to the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -1685,6 +1696,7 @@ public function updatePetWithHttpInfo($pet, ?int $hostIndex = null, array $varia * * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. * if needed, use the 'variables' parameter to pass variables to the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -1724,6 +1736,7 @@ function ($response) { * * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. * if needed, use the 'variables' parameter to pass variables to the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -1779,6 +1792,7 @@ function ($exception) { * * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. * if needed, use the 'variables' parameter to pass variables to the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -1905,6 +1919,10 @@ public function updatePetRequest($pet, ?int $hostIndex = null, array $variables protected function getHostSettingsForupdatePet(): array { return [ + [ + "url" => "http://localhost/v2", + "description" => "No description provided", + ], [ "url" => "http://petstore.swagger.io/v2", "description" => "No description provided", diff --git a/samples/client/petstore/php/psr-18/lib/Api/PetApi.php b/samples/client/petstore/php/psr-18/lib/Api/PetApi.php index a002591b50c4..4148c86db0a8 100644 --- a/samples/client/petstore/php/psr-18/lib/Api/PetApi.php +++ b/samples/client/petstore/php/psr-18/lib/Api/PetApi.php @@ -180,6 +180,7 @@ public function getConfig() * Add a new pet to the store * * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -201,6 +202,7 @@ public function addPet($pet) * Add a new pet to the store * * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -258,6 +260,7 @@ public function addPetWithHttpInfo($pet) * Add a new pet to the store * * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -283,6 +286,7 @@ function ($response) { * Add a new pet to the store * * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -323,6 +327,7 @@ function (HttpException $exception) { * Create request for operation 'addPet' * * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -405,7 +410,7 @@ public function addPetRequest($pet) $headers ); - $operationHosts = ["http://petstore.swagger.io/v2", "http://path-server-test.petstore.local/v2", "http://{server}.swagger.io:{port}/v2"]; + $operationHosts = ["http://localhost/v2", "http://petstore.swagger.io/v2", "http://path-server-test.petstore.local/v2", "http://{server}.swagger.io:{port}/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)); } @@ -1432,6 +1437,7 @@ public function getPetByIdRequest($pet_id) * Update an existing pet * * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -1453,6 +1459,7 @@ public function updatePet($pet) * Update an existing pet * * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -1510,6 +1517,7 @@ public function updatePetWithHttpInfo($pet) * Update an existing pet * * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -1535,6 +1543,7 @@ function ($response) { * Update an existing pet * * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -1575,6 +1584,7 @@ function (HttpException $exception) { * Create request for operation 'updatePet' * * This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host. + * URL: http://localhost/v2 * URL: http://petstore.swagger.io/v2 * URL: http://path-server-test.petstore.local/v2 * URL: http://{server}.swagger.io:{port}/v2 @@ -1657,7 +1667,7 @@ public function updatePetRequest($pet) $headers ); - $operationHosts = ["http://petstore.swagger.io/v2", "http://path-server-test.petstore.local/v2", "http://{server}.swagger.io:{port}/v2"]; + $operationHosts = ["http://localhost/v2", "http://petstore.swagger.io/v2", "http://path-server-test.petstore.local/v2", "http://{server}.swagger.io:{port}/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)); } From 572a69f6bcbab426103c77de55c069bd74b5e7fb Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 28 Jul 2025 17:56:15 +0800 Subject: [PATCH 02/10] trigger build failure --- .../client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php | 4 ++++ 1 file changed, 4 insertions(+) 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 b856a8244825..860862858f23 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php @@ -1,3 +1,7 @@ +fklasdjf;klas;f; + +skldfj;aslkfjdl;as;j; + Date: Mon, 28 Jul 2025 18:00:45 +0800 Subject: [PATCH 03/10] update workflow --- .github/workflows/samples-php-client.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/samples-php-client.yaml b/.github/workflows/samples-php-client.yaml index df47d5fea0aa..ded8bad29dc9 100644 --- a/.github/workflows/samples-php-client.yaml +++ b/.github/workflows/samples-php-client.yaml @@ -42,4 +42,4 @@ jobs: run: composer install - name: phpunit working-directory: ${{ matrix.sample }} - run: vendor/bin/phpunit + run: vendor/bin/phpunit tests From 0e5578da59898b48fd42c5d49a46eb58debc9c72 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 28 Jul 2025 18:01:49 +0800 Subject: [PATCH 04/10] Revert "trigger build failure" This reverts commit 572a69f6bcbab426103c77de55c069bd74b5e7fb. --- .../client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php | 4 ---- 1 file changed, 4 deletions(-) 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 860862858f23..b856a8244825 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php @@ -1,7 +1,3 @@ -fklasdjf;klas;f; - -skldfj;aslkfjdl;as;j; - Date: Mon, 28 Jul 2025 18:08:02 +0800 Subject: [PATCH 05/10] update tests --- .../tests/ServerVariablesInOperationTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/client/petstore/php/OpenAPIClient-php/tests/ServerVariablesInOperationTest.php b/samples/client/petstore/php/OpenAPIClient-php/tests/ServerVariablesInOperationTest.php index 208ae7ed329d..064ffe60f9e1 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/tests/ServerVariablesInOperationTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/tests/ServerVariablesInOperationTest.php @@ -30,10 +30,10 @@ public function testServerVariablesInOperation(): void $this->api->addPet($this->pet, 2); $request = $this->fakeHttpClient->getLastRequest(); - $this->assertEquals('petstore.swagger.io', $request->getUri()->getHost(), 'Server variable set to default value.'); + $this->assertEquals('path-server-test.petstore.local', $request->getUri()->getHost(), 'Server variable set to default value.'); # Test variables substitution - $this->api->addPet($this->pet, 2, [ 'server' => 'qa-petstore', 'port' => '8080']); + $this->api->addPet($this->pet, 3, [ 'server' => 'qa-petstore', 'port' => '8080']); $request = $this->fakeHttpClient->getLastRequest(); $this->assertEquals('qa-petstore.swagger.io', $request->getUri()->getHost(), 'Server set to "qa-petstore"'); @@ -43,7 +43,7 @@ public function testServerVariablesInOperation(): void public function testLegacyServerChoiceInOperation(): void { # Test legacy behavior (set server using api->setHostIndex() - $this->api->setHostIndex(1); + $this->api->setHostIndex(2); $this->api->addPet($this->pet); $request = $this->fakeHttpClient->getLastRequest(); @@ -53,6 +53,6 @@ public function testLegacyServerChoiceInOperation(): void public function testInvalidVariableValueInOperation(): void { $this->expectException(InvalidArgumentException::class); - $this->api->addPet($this->pet, 2,['server' => 'invalid-value']); + $this->api->addPet($this->pet, 3,['server' => 'invalid-value']); } } From b343f672f12c3c03b2cbcab8e816ea12302fb7e5 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 28 Jul 2025 18:13:05 +0800 Subject: [PATCH 06/10] update tests --- .../client/petstore/php/OpenAPIClient-php/tests/PetApiTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/client/petstore/php/OpenAPIClient-php/tests/PetApiTest.php b/samples/client/petstore/php/OpenAPIClient-php/tests/PetApiTest.php index bd1c2fb2a8a9..b1c6ebf0bbca 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/tests/PetApiTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/tests/PetApiTest.php @@ -42,7 +42,7 @@ public static function setUpBeforeClass(): void $newPet->setTags(array($tag)); $newPet->setCategory($category); - $config = new Configuration(); + $config = (new Configuration())->setHost('http://localhost/v2'); $petApi = new Api\PetApi(null, $config); } From e074101e03737ca346098ed61ba21742a34fc9b9 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 28 Jul 2025 18:16:45 +0800 Subject: [PATCH 07/10] update test --- .../client/petstore/php/OpenAPIClient-php/tests/PetApiTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/client/petstore/php/OpenAPIClient-php/tests/PetApiTest.php b/samples/client/petstore/php/OpenAPIClient-php/tests/PetApiTest.php index b1c6ebf0bbca..7f98eee42053 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/tests/PetApiTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/tests/PetApiTest.php @@ -49,7 +49,7 @@ public static function setUpBeforeClass(): void public function setUp(): void { - $this->api = new Api\PetApi(); + $this->api = $petApi; } public function testGetPetById() From 0996add2739c7110de861c568ef07421b6fcd7e1 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 28 Jul 2025 18:19:03 +0800 Subject: [PATCH 08/10] fix tests --- .../petstore/php/OpenAPIClient-php/tests/PetApiTest.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/samples/client/petstore/php/OpenAPIClient-php/tests/PetApiTest.php b/samples/client/petstore/php/OpenAPIClient-php/tests/PetApiTest.php index 7f98eee42053..eb32525895b3 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/tests/PetApiTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/tests/PetApiTest.php @@ -41,15 +41,12 @@ public static function setUpBeforeClass(): void $newPet->setTags(array($tag)); $newPet->setCategory($category); - - $config = (new Configuration())->setHost('http://localhost/v2'); - $petApi = new Api\PetApi(null, $config); - } public function setUp(): void { - $this->api = $petApi; + $config = (new Configuration())->setHost('http://localhost/v2'); + $this->api = new Api\PetApi(null, $config); } public function testGetPetById() From f119c2db085bf7b3a289b90df2cd5c691c5b9750 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 28 Jul 2025 18:21:28 +0800 Subject: [PATCH 09/10] fix async test --- .../client/petstore/php/OpenAPIClient-php/tests/AsyncTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/client/petstore/php/OpenAPIClient-php/tests/AsyncTest.php b/samples/client/petstore/php/OpenAPIClient-php/tests/AsyncTest.php index 421eef565ce1..50d71e6e9e35 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/tests/AsyncTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/tests/AsyncTest.php @@ -16,7 +16,8 @@ class AsyncTest extends TestCase public function setUp(): void { - $this->api = new Api\PetApi(); + $config = (new Configuration())->setHost('http://localhost/v2'); + $this->api = new Api\PetApi(null, $config); $this->petId = 10005; $pet = new Model\Pet; From f66a2a087a015556f5c8e2ce35f8cca5720dbe04 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 28 Jul 2025 18:25:05 +0800 Subject: [PATCH 10/10] update tests --- .../petstore/php/OpenAPIClient-php/tests/DebugTest.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/samples/client/petstore/php/OpenAPIClient-php/tests/DebugTest.php b/samples/client/petstore/php/OpenAPIClient-php/tests/DebugTest.php index b14dd018df03..050869768d89 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/tests/DebugTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/tests/DebugTest.php @@ -11,15 +11,16 @@ public static function setUpBeforeClass(): void parent::setUpBeforeClass(); $newPet = new Model\Pet; $newPet->setId(1); - $newPet->setName("PHP Unit Test"); - (new Api\PetApi())->addPetWithHttpInfo($newPet); + $newPet->setName("PHP Unit Test"); + $config = (new Configuration())->setHost('http://localhost/v2'); + (new Api\PetApi(null, $config))->addPetWithHttpInfo($newPet); } public function testEnableDebugOutput() { $this->expectOutputRegex('#GET /v2/pet/1 HTTP/1.1#'); - $config = new Configuration(); + $config = (new Configuration())->setHost('http://localhost/v2'); $config->setDebug(true); $api = new Api\PetApi(null, $config); $api->getPetById(1); @@ -29,7 +30,7 @@ public function testEnableDebugOutputAsync() { $this->expectOutputRegex('#GET /v2/pet/1 HTTP/1.1#'); - $config = new Configuration(); + $config = (new Configuration())->setHost('http://localhost/v2'); $config->setDebug(true); $api = new Api\PetApi(null, $config); $promise = $api->getPetByIdAsync(1);