diff --git a/modules/swagger-codegen/src/main/resources/php/README.mustache b/modules/swagger-codegen/src/main/resources/php/README.mustache index eeff364b156..f130f944d67 100644 --- a/modules/swagger-codegen/src/main/resources/php/README.mustache +++ b/modules/swagger-codegen/src/main/resources/php/README.mustache @@ -68,22 +68,27 @@ Please follow the [installation procedure](#installation--usage) and then run th require_once(__DIR__ . '/vendor/autoload.php'); {{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} // Configure HTTP basic authorization: {{{name}}} -{{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setUsername('YOUR_USERNAME'); -{{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setPassword('YOUR_PASSWORD');{{/isBasic}}{{#isApiKey}} + ->setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD');{{/isBasic}}{{#isApiKey}} // Configure API key authorization: {{{name}}} -{{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setApiKey('{{{keyParamName}}}', 'YOUR_API_KEY'); +$config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setApiKey('{{{keyParamName}}}', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed -// {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setApiKeyPrefix('{{{keyParamName}}}', 'Bearer');{{/isApiKey}}{{#isOAuth}} +// $config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setApiKeyPrefix('{{{keyParamName}}}', 'Bearer');{{/isApiKey}}{{#isOAuth}} // Configure OAuth2 access token for authorization: {{{name}}} -{{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');{{/isOAuth}}{{/authMethods}} +$config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');{{/isOAuth}}{{/authMethods}} {{/hasAuthMethods}} -$api_instance = new {{invokerPackage}}\Api\{{classname}}(); +$apiInstance = new {{invokerPackage}}\Api\{{classname}}( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(){{#hasAuthMethods}}, + $config{{/hasAuthMethods}} +); {{#allParams}}${{paramName}} = {{{example}}}; // {{{dataType}}} | {{{description}}} {{/allParams}} try { - {{#returnType}}$result = {{/returnType}}$api_instance->{{{operationId}}}({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} + {{#returnType}}$result = {{/returnType}}$apiInstance->{{{operationId}}}({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} print_r($result);{{/returnType}} } catch (Exception $e) { echo 'Exception when calling {{classname}}->{{operationId}}: ', $e->getMessage(), PHP_EOL; diff --git a/modules/swagger-codegen/src/main/resources/php/api_doc.mustache b/modules/swagger-codegen/src/main/resources/php/api_doc.mustache index 6d0ad8ebbb4..4118b83c30d 100644 --- a/modules/swagger-codegen/src/main/resources/php/api_doc.mustache +++ b/modules/swagger-codegen/src/main/resources/php/api_doc.mustache @@ -23,22 +23,29 @@ Method | HTTP request | Description require_once(__DIR__ . '/vendor/autoload.php'); {{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} // Configure HTTP basic authorization: {{{name}}} -{{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setUsername('YOUR_USERNAME'); -{{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setPassword('YOUR_PASSWORD');{{/isBasic}}{{#isApiKey}} +$config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration() + ->setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); +{{/isBasic}}{{#isApiKey}} // Configure API key authorization: {{{name}}} -{{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setApiKey('{{{keyParamName}}}', 'YOUR_API_KEY'); +$config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setApiKey('{{{keyParamName}}}', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed -// {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setApiKeyPrefix('{{{keyParamName}}}', 'Bearer');{{/isApiKey}}{{#isOAuth}} +// $config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setApiKeyPrefix('{{{keyParamName}}}', 'Bearer');{{/isApiKey}}{{#isOAuth}} // Configure OAuth2 access token for authorization: {{{name}}} -{{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');{{/isOAuth}}{{/authMethods}} +$config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');{{/isOAuth}}{{/authMethods}} {{/hasAuthMethods}} -$api_instance = new {{invokerPackage}}\Api\{{classname}}(new \Http\Adapter\Guzzle6\Client()); +$apiInstance = new {{invokerPackage}}\Api\{{classname}}( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(){{#hasAuthMethods}}, + $config{{/hasAuthMethods}} +); {{#allParams}}${{paramName}} = {{{example}}}; // {{{dataType}}} | {{{description}}} {{/allParams}} try { - {{#returnType}}$result = {{/returnType}}$api_instance->{{{operationId}}}({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} + {{#returnType}}$result = {{/returnType}}$apiInstance->{{{operationId}}}({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} print_r($result);{{/returnType}} } catch (Exception $e) { echo 'Exception when calling {{classname}}->{{operationId}}: ', $e->getMessage(), PHP_EOL; diff --git a/samples/client/petstore-security-test/php/SwaggerClient-php/README.md b/samples/client/petstore-security-test/php/SwaggerClient-php/README.md index 3c73985e40c..1f5c98d4da7 100644 --- a/samples/client/petstore-security-test/php/SwaggerClient-php/README.md +++ b/samples/client/petstore-security-test/php/SwaggerClient-php/README.md @@ -56,11 +56,15 @@ Please follow the [installation procedure](#installation--usage) and then run th testCodeInjectEndRnNR($test_code_inject____end____rn_n_r); + $apiInstance->testCodeInjectEndRnNR($test_code_inject____end____rn_n_r); } catch (Exception $e) { echo 'Exception when calling FakeApi->testCodeInjectEndRnNR: ', $e->getMessage(), PHP_EOL; } diff --git a/samples/client/petstore-security-test/php/SwaggerClient-php/docs/Api/FakeApi.md b/samples/client/petstore-security-test/php/SwaggerClient-php/docs/Api/FakeApi.md index 445abaf0855..6b76f9e222c 100644 --- a/samples/client/petstore-security-test/php/SwaggerClient-php/docs/Api/FakeApi.md +++ b/samples/client/petstore-security-test/php/SwaggerClient-php/docs/Api/FakeApi.md @@ -17,11 +17,15 @@ To test code injection *_/ ' \" =end -- \\r\\n \\n \\r testCodeInjectEndRnNR($test_code_inject____end____rn_n_r); + $apiInstance->testCodeInjectEndRnNR($test_code_inject____end____rn_n_r); } catch (Exception $e) { echo 'Exception when calling FakeApi->testCodeInjectEndRnNR: ', $e->getMessage(), PHP_EOL; } diff --git a/samples/client/petstore/php/SwaggerClient-php/README.md b/samples/client/petstore/php/SwaggerClient-php/README.md index 087c3105f8d..112c5b8ab08 100644 --- a/samples/client/petstore/php/SwaggerClient-php/README.md +++ b/samples/client/petstore/php/SwaggerClient-php/README.md @@ -56,11 +56,15 @@ Please follow the [installation procedure](#installation--usage) and then run th testSpecialTags($body); + $result = $apiInstance->testSpecialTags($body); print_r($result); } catch (Exception $e) { echo 'Exception when calling AnotherFakeApi->testSpecialTags: ', $e->getMessage(), PHP_EOL; diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Api/AnotherFakeApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/Api/AnotherFakeApi.md index 5b443618999..9eaff87384b 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Api/AnotherFakeApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Api/AnotherFakeApi.md @@ -19,11 +19,15 @@ To test special tags testSpecialTags($body); + $result = $apiInstance->testSpecialTags($body); print_r($result); } catch (Exception $e) { echo 'Exception when calling AnotherFakeApi->testSpecialTags: ', $e->getMessage(), PHP_EOL; diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Api/FakeApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/Api/FakeApi.md index 5a5bd8c3bda..da5558c386f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Api/FakeApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Api/FakeApi.md @@ -27,11 +27,15 @@ Test serialization of outer boolean types fakeOuterBooleanSerialize($body); + $result = $apiInstance->fakeOuterBooleanSerialize($body); print_r($result); } catch (Exception $e) { echo 'Exception when calling FakeApi->fakeOuterBooleanSerialize: ', $e->getMessage(), PHP_EOL; @@ -72,11 +76,15 @@ Test serialization of object with outer number type fakeOuterCompositeSerialize($body); + $result = $apiInstance->fakeOuterCompositeSerialize($body); print_r($result); } catch (Exception $e) { echo 'Exception when calling FakeApi->fakeOuterCompositeSerialize: ', $e->getMessage(), PHP_EOL; @@ -117,11 +125,15 @@ Test serialization of outer number types fakeOuterNumberSerialize($body); + $result = $apiInstance->fakeOuterNumberSerialize($body); print_r($result); } catch (Exception $e) { echo 'Exception when calling FakeApi->fakeOuterNumberSerialize: ', $e->getMessage(), PHP_EOL; @@ -162,11 +174,15 @@ Test serialization of outer string types fakeOuterStringSerialize($body); + $result = $apiInstance->fakeOuterStringSerialize($body); print_r($result); } catch (Exception $e) { echo 'Exception when calling FakeApi->fakeOuterStringSerialize: ', $e->getMessage(), PHP_EOL; @@ -207,11 +223,15 @@ To test \"client\" model testClientModel($body); + $result = $apiInstance->testClientModel($body); print_r($result); } catch (Exception $e) { echo 'Exception when calling FakeApi->testClientModel: ', $e->getMessage(), PHP_EOL; @@ -253,10 +273,17 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン require_once(__DIR__ . '/vendor/autoload.php'); // Configure HTTP basic authorization: http_basic_test -Swagger\Client\Configuration::getDefaultConfiguration()->setUsername('YOUR_USERNAME'); -Swagger\Client\Configuration::getDefaultConfiguration()->setPassword('YOUR_PASSWORD'); +$config = Swagger\Client\Configuration::getDefaultConfiguration() + ->setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); -$api_instance = new Swagger\Client\Api\FakeApi(new \Http\Adapter\Guzzle6\Client()); + +$apiInstance = new Swagger\Client\Api\FakeApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); $number = 8.14; // float | None $double = 1.2; // double | None $pattern_without_delimiter = "pattern_without_delimiter_example"; // string | None @@ -273,7 +300,7 @@ $password = "password_example"; // string | None $callback = "callback_example"; // string | None try { - $api_instance->testEndpointParameters($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback); + $apiInstance->testEndpointParameters($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback); } catch (Exception $e) { echo 'Exception when calling FakeApi->testEndpointParameters: ', $e->getMessage(), PHP_EOL; } @@ -326,7 +353,11 @@ To test enum parameters testEnumParameters($enum_form_string_array, $enum_form_string, $enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double); + $apiInstance->testEnumParameters($enum_form_string_array, $enum_form_string, $enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double); } catch (Exception $e) { echo 'Exception when calling FakeApi->testEnumParameters: ', $e->getMessage(), PHP_EOL; } @@ -384,11 +415,15 @@ test inline additionalProperties testInlineAdditionalProperties($param); + $apiInstance->testInlineAdditionalProperties($param); } catch (Exception $e) { echo 'Exception when calling FakeApi->testInlineAdditionalProperties: ', $e->getMessage(), PHP_EOL; } @@ -428,12 +463,16 @@ test json serialization of form data testJsonFormData($param, $param2); + $apiInstance->testJsonFormData($param, $param2); } catch (Exception $e) { echo 'Exception when calling FakeApi->testJsonFormData: ', $e->getMessage(), PHP_EOL; } diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Api/FakeClassnameTags123Api.md b/samples/client/petstore/php/SwaggerClient-php/docs/Api/FakeClassnameTags123Api.md index 8f826708f0c..af8699f0961 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Api/FakeClassnameTags123Api.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Api/FakeClassnameTags123Api.md @@ -18,15 +18,20 @@ To test class name in snake case require_once(__DIR__ . '/vendor/autoload.php'); // Configure API key authorization: api_key_query -Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key_query', 'YOUR_API_KEY'); +$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key_query', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed -// Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key_query', 'Bearer'); - -$api_instance = new Swagger\Client\Api\FakeClassnameTags123Api(new \Http\Adapter\Guzzle6\Client()); +// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key_query', 'Bearer'); + +$apiInstance = new Swagger\Client\Api\FakeClassnameTags123Api( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); $body = new \Swagger\Client\Model\Client(); // \Swagger\Client\Model\Client | client model try { - $result = $api_instance->testClassname($body); + $result = $apiInstance->testClassname($body); print_r($result); } catch (Exception $e) { echo 'Exception when calling FakeClassnameTags123Api->testClassname: ', $e->getMessage(), PHP_EOL; diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Api/PetApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/Api/PetApi.md index 2c5edb0414e..46e42007fac 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Api/PetApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Api/PetApi.md @@ -27,13 +27,18 @@ Add a new pet to the store require_once(__DIR__ . '/vendor/autoload.php'); // Configure OAuth2 access token for authorization: petstore_auth -Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); - -$api_instance = new Swagger\Client\Api\PetApi(new \Http\Adapter\Guzzle6\Client()); +$config = Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); + +$apiInstance = new Swagger\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); $body = new \Swagger\Client\Model\Pet(); // \Swagger\Client\Model\Pet | Pet object that needs to be added to the store try { - $api_instance->addPet($body); + $apiInstance->addPet($body); } catch (Exception $e) { echo 'Exception when calling PetApi->addPet: ', $e->getMessage(), PHP_EOL; } @@ -74,14 +79,19 @@ Deletes a pet require_once(__DIR__ . '/vendor/autoload.php'); // Configure OAuth2 access token for authorization: petstore_auth -Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); - -$api_instance = new Swagger\Client\Api\PetApi(new \Http\Adapter\Guzzle6\Client()); +$config = Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); + +$apiInstance = new Swagger\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); $pet_id = 789; // int | Pet id to delete $api_key = "api_key_example"; // string | try { - $api_instance->deletePet($pet_id, $api_key); + $apiInstance->deletePet($pet_id, $api_key); } catch (Exception $e) { echo 'Exception when calling PetApi->deletePet: ', $e->getMessage(), PHP_EOL; } @@ -123,13 +133,18 @@ Multiple status values can be provided with comma separated strings require_once(__DIR__ . '/vendor/autoload.php'); // Configure OAuth2 access token for authorization: petstore_auth -Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); - -$api_instance = new Swagger\Client\Api\PetApi(new \Http\Adapter\Guzzle6\Client()); +$config = Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); + +$apiInstance = new Swagger\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); $status = array("status_example"); // string[] | Status values that need to be considered for filter try { - $result = $api_instance->findPetsByStatus($status); + $result = $apiInstance->findPetsByStatus($status); print_r($result); } catch (Exception $e) { echo 'Exception when calling PetApi->findPetsByStatus: ', $e->getMessage(), PHP_EOL; @@ -171,13 +186,18 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 require_once(__DIR__ . '/vendor/autoload.php'); // Configure OAuth2 access token for authorization: petstore_auth -Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); - -$api_instance = new Swagger\Client\Api\PetApi(new \Http\Adapter\Guzzle6\Client()); +$config = Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); + +$apiInstance = new Swagger\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); $tags = array("tags_example"); // string[] | Tags to filter by try { - $result = $api_instance->findPetsByTags($tags); + $result = $apiInstance->findPetsByTags($tags); print_r($result); } catch (Exception $e) { echo 'Exception when calling PetApi->findPetsByTags: ', $e->getMessage(), PHP_EOL; @@ -219,15 +239,20 @@ Returns a single pet require_once(__DIR__ . '/vendor/autoload.php'); // Configure API key authorization: api_key -Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key', 'YOUR_API_KEY'); +$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed -// Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'Bearer'); - -$api_instance = new Swagger\Client\Api\PetApi(new \Http\Adapter\Guzzle6\Client()); +// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'Bearer'); + +$apiInstance = new Swagger\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); $pet_id = 789; // int | ID of pet to return try { - $result = $api_instance->getPetById($pet_id); + $result = $apiInstance->getPetById($pet_id); print_r($result); } catch (Exception $e) { echo 'Exception when calling PetApi->getPetById: ', $e->getMessage(), PHP_EOL; @@ -269,13 +294,18 @@ Update an existing pet require_once(__DIR__ . '/vendor/autoload.php'); // Configure OAuth2 access token for authorization: petstore_auth -Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); - -$api_instance = new Swagger\Client\Api\PetApi(new \Http\Adapter\Guzzle6\Client()); +$config = Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); + +$apiInstance = new Swagger\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); $body = new \Swagger\Client\Model\Pet(); // \Swagger\Client\Model\Pet | Pet object that needs to be added to the store try { - $api_instance->updatePet($body); + $apiInstance->updatePet($body); } catch (Exception $e) { echo 'Exception when calling PetApi->updatePet: ', $e->getMessage(), PHP_EOL; } @@ -316,15 +346,20 @@ Updates a pet in the store with form data require_once(__DIR__ . '/vendor/autoload.php'); // Configure OAuth2 access token for authorization: petstore_auth -Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); - -$api_instance = new Swagger\Client\Api\PetApi(new \Http\Adapter\Guzzle6\Client()); +$config = Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); + +$apiInstance = new Swagger\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); $pet_id = 789; // int | ID of pet that needs to be updated $name = "name_example"; // string | Updated name of the pet $status = "status_example"; // string | Updated status of the pet try { - $api_instance->updatePetWithForm($pet_id, $name, $status); + $apiInstance->updatePetWithForm($pet_id, $name, $status); } catch (Exception $e) { echo 'Exception when calling PetApi->updatePetWithForm: ', $e->getMessage(), PHP_EOL; } @@ -367,15 +402,20 @@ uploads an image require_once(__DIR__ . '/vendor/autoload.php'); // Configure OAuth2 access token for authorization: petstore_auth -Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); - -$api_instance = new Swagger\Client\Api\PetApi(new \Http\Adapter\Guzzle6\Client()); +$config = Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); + +$apiInstance = new Swagger\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); $pet_id = 789; // int | ID of pet to update $additional_metadata = "additional_metadata_example"; // string | Additional data to pass to server $file = "/path/to/file.txt"; // \SplFileObject | file to upload try { - $result = $api_instance->uploadFile($pet_id, $additional_metadata, $file); + $result = $apiInstance->uploadFile($pet_id, $additional_metadata, $file); print_r($result); } catch (Exception $e) { echo 'Exception when calling PetApi->uploadFile: ', $e->getMessage(), PHP_EOL; diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Api/StoreApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/Api/StoreApi.md index 9daa65eba7b..87cec61aa7b 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Api/StoreApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Api/StoreApi.md @@ -22,11 +22,15 @@ For valid response try integer IDs with value < 1000. Anything above 1000 or non deleteOrder($order_id); + $apiInstance->deleteOrder($order_id); } catch (Exception $e) { echo 'Exception when calling StoreApi->deleteOrder: ', $e->getMessage(), PHP_EOL; } @@ -67,14 +71,19 @@ Returns a map of status codes to quantities require_once(__DIR__ . '/vendor/autoload.php'); // Configure API key authorization: api_key -Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key', 'YOUR_API_KEY'); +$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed -// Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'Bearer'); +// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'Bearer'); -$api_instance = new Swagger\Client\Api\StoreApi(new \Http\Adapter\Guzzle6\Client()); +$apiInstance = new Swagger\Client\Api\StoreApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); try { - $result = $api_instance->getInventory(); + $result = $apiInstance->getInventory(); print_r($result); } catch (Exception $e) { echo 'Exception when calling StoreApi->getInventory: ', $e->getMessage(), PHP_EOL; @@ -112,11 +121,15 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge getOrderById($order_id); + $result = $apiInstance->getOrderById($order_id); print_r($result); } catch (Exception $e) { echo 'Exception when calling StoreApi->getOrderById: ', $e->getMessage(), PHP_EOL; @@ -157,11 +170,15 @@ Place an order for a pet placeOrder($body); + $result = $apiInstance->placeOrder($body); print_r($result); } catch (Exception $e) { echo 'Exception when calling StoreApi->placeOrder: ', $e->getMessage(), PHP_EOL; diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Api/UserApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/Api/UserApi.md index a1b3fdf3089..52b0a351904 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Api/UserApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Api/UserApi.md @@ -26,11 +26,15 @@ This can only be done by the logged in user. createUser($body); + $apiInstance->createUser($body); } catch (Exception $e) { echo 'Exception when calling UserApi->createUser: ', $e->getMessage(), PHP_EOL; } @@ -70,11 +74,15 @@ Creates list of users with given input array createUsersWithArrayInput($body); + $apiInstance->createUsersWithArrayInput($body); } catch (Exception $e) { echo 'Exception when calling UserApi->createUsersWithArrayInput: ', $e->getMessage(), PHP_EOL; } @@ -114,11 +122,15 @@ Creates list of users with given input array createUsersWithListInput($body); + $apiInstance->createUsersWithListInput($body); } catch (Exception $e) { echo 'Exception when calling UserApi->createUsersWithListInput: ', $e->getMessage(), PHP_EOL; } @@ -158,11 +170,15 @@ This can only be done by the logged in user. deleteUser($username); + $apiInstance->deleteUser($username); } catch (Exception $e) { echo 'Exception when calling UserApi->deleteUser: ', $e->getMessage(), PHP_EOL; } @@ -202,11 +218,15 @@ Get user by user name getUserByName($username); + $result = $apiInstance->getUserByName($username); print_r($result); } catch (Exception $e) { echo 'Exception when calling UserApi->getUserByName: ', $e->getMessage(), PHP_EOL; @@ -247,12 +267,16 @@ Logs user into the system loginUser($username, $password); + $result = $apiInstance->loginUser($username, $password); print_r($result); } catch (Exception $e) { echo 'Exception when calling UserApi->loginUser: ', $e->getMessage(), PHP_EOL; @@ -294,10 +318,14 @@ Logs out current logged in user session logoutUser(); + $apiInstance->logoutUser(); } catch (Exception $e) { echo 'Exception when calling UserApi->logoutUser: ', $e->getMessage(), PHP_EOL; } @@ -334,12 +362,16 @@ This can only be done by the logged in user. updateUser($username, $body); + $apiInstance->updateUser($username, $body); } catch (Exception $e) { echo 'Exception when calling UserApi->updateUser: ', $e->getMessage(), PHP_EOL; }