Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/samples-php-client.yaml
Original file line number Diff line number Diff line change
@@ -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 tests
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -80,6 +80,7 @@ try {




### Return type

void (empty response body)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -405,6 +406,7 @@ try {




### Return type

void (empty response body)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -82,6 +82,7 @@ try {




### Return type

void (empty response body)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -407,6 +408,7 @@ try {




### Return type

void (empty response body)
Expand Down
18 changes: 18 additions & 0 deletions samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,12 @@ public static function setUpBeforeClass(): void

$newPet->setTags(array($tag));
$newPet->setCategory($category);

$config = new Configuration();
$petApi = new Api\PetApi(null, $config);

}

public function setUp(): void
{
$this->api = new Api\PetApi();
$config = (new Configuration())->setHost('http://localhost/v2');
$this->api = new Api\PetApi(null, $config);
}

public function testGetPetById()
Expand Down
Loading
Loading