diff --git a/.github/workflows/test-framework-php.yml b/.github/workflows/test-framework-php.yml index 0b5e4b32745..e3dfebda70f 100644 --- a/.github/workflows/test-framework-php.yml +++ b/.github/workflows/test-framework-php.yml @@ -160,7 +160,7 @@ jobs: - name: Setup PHP with composer v2 uses: shivammathur/setup-php@v2 with: - php-version: '7.4' + php-version: '8.3' tools: composer:v2 ############################################### ##### END DYNAMIC: Dependent on build environment diff --git a/.github/workflows/test-framework-v2-php.yml b/.github/workflows/test-framework-v2-php.yml index af6a0e7083d..7c7e69da723 100644 --- a/.github/workflows/test-framework-v2-php.yml +++ b/.github/workflows/test-framework-v2-php.yml @@ -143,7 +143,7 @@ jobs: - name: Setup PHP with composer v2 uses: shivammathur/setup-php@v2 with: - php-version: '7.4' + php-version: '8.3' tools: composer:v2 ############################################### ##### END DYNAMIC: Dependent on build environment diff --git a/.github/workflows/test-framework-v3-php.yml b/.github/workflows/test-framework-v3-php.yml index ae871aba9cb..3954674e242 100644 --- a/.github/workflows/test-framework-v3-php.yml +++ b/.github/workflows/test-framework-v3-php.yml @@ -145,7 +145,7 @@ jobs: - name: Setup PHP with composer v2 uses: shivammathur/setup-php@v2 with: - php-version: '7.4' + php-version: '8.3' tools: composer:v2 ############################################### ##### END DYNAMIC: Dependent on build environment diff --git a/.github/workflows/test-generation-v2.yml b/.github/workflows/test-generation-v2.yml index 0185a2159c4..4825397a804 100644 --- a/.github/workflows/test-generation-v2.yml +++ b/.github/workflows/test-generation-v2.yml @@ -410,7 +410,7 @@ jobs: - name: Setup PHP with composer v2 uses: shivammathur/setup-php@v2 with: - php-version: '7.4' + php-version: '8.3' tools: composer:v2 ############################################### ##### END DYNAMIC: Dependent on build environment diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java index ffaed0e5e16..4fe7304f7ee 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java @@ -316,7 +316,7 @@ public void processOpts() { supportingFiles.add(new SupportingFile("README.mustache", getPackagePath(), "README.md")); supportingFiles.add(new SupportingFile("phpunit.xml.mustache", getPackagePath(), "phpunit.xml.dist")); supportingFiles.add(new SupportingFile(".travis.yml", getPackagePath(), ".travis.yml")); - supportingFiles.add(new SupportingFile(".php_cs", getPackagePath(), ".php_cs")); + supportingFiles.add(new SupportingFile(".php-cs-fixer.php", getPackagePath(), ".php-cs-fixer.php")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", getPackagePath(), "git_push.sh")); } diff --git a/modules/swagger-codegen/src/main/resources/php-symfony/composer.mustache b/modules/swagger-codegen/src/main/resources/php-symfony/composer.mustache index 5d6156df550..b9ef879091a 100644 --- a/modules/swagger-codegen/src/main/resources/php-symfony/composer.mustache +++ b/modules/swagger-codegen/src/main/resources/php-symfony/composer.mustache @@ -30,7 +30,7 @@ "require-dev": { "phpunit/phpunit": "~4.8", "satooshi/php-coveralls": "~1.0", - "squizlabs/php_codesniffer": "~2.6", + "squizlabs/php_codesniffer": "^3.0", "friendsofphp/php-cs-fixer": "~1.12", "symfony/browser-kit": "*", "hoa/regex": "~1.0" diff --git a/modules/swagger-codegen/src/main/resources/php/.php_cs b/modules/swagger-codegen/src/main/resources/php/.php-cs-fixer.php similarity index 91% rename from modules/swagger-codegen/src/main/resources/php/.php_cs rename to modules/swagger-codegen/src/main/resources/php/.php-cs-fixer.php index 4fbe53ec5ff..dc702622b95 100644 --- a/modules/swagger-codegen/src/main/resources/php/.php_cs +++ b/modules/swagger-codegen/src/main/resources/php/.php-cs-fixer.php @@ -1,7 +1,8 @@ setUsingCache(true) + ->setRiskyAllowed(true) ->setRules([ '@PSR2' => true, 'ordered_imports' => true, diff --git a/modules/swagger-codegen/src/main/resources/php/.travis.yml b/modules/swagger-codegen/src/main/resources/php/.travis.yml index d77f3825f6f..989be894218 100644 --- a/modules/swagger-codegen/src/main/resources/php/.travis.yml +++ b/modules/swagger-codegen/src/main/resources/php/.travis.yml @@ -1,10 +1,6 @@ language: php sudo: false php: - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - hhvm + - 8.3 before_install: "composer install" script: "vendor/bin/phpunit" diff --git a/modules/swagger-codegen/src/main/resources/php/README.mustache b/modules/swagger-codegen/src/main/resources/php/README.mustache index 18bb80f7ce0..fea61dadffe 100644 --- a/modules/swagger-codegen/src/main/resources/php/README.mustache +++ b/modules/swagger-codegen/src/main/resources/php/README.mustache @@ -19,7 +19,7 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) ## Requirements -PHP 5.5 and later +PHP 8.3 and later ## Installation & Usage ### Composer @@ -59,7 +59,7 @@ composer install ./vendor/bin/phpunit ``` -**Note:** Running tests requires PHP 7.2 or later, while the runtime library supports PHP 5.5 and later. +**Note:** Running tests requires PHP 8.3 or later. ## Getting Started diff --git a/modules/swagger-codegen/src/main/resources/php/api.mustache b/modules/swagger-codegen/src/main/resources/php/api.mustache index e0b01e1f678..5b11cb3b1d1 100644 --- a/modules/swagger-codegen/src/main/resources/php/api.mustache +++ b/modules/swagger-codegen/src/main/resources/php/api.mustache @@ -20,7 +20,8 @@ namespace {{apiPackage}}; use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\ResponseException; +use GuzzleHttp\Exception\TransferException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -60,9 +61,9 @@ use {{invokerPackage}}\ObjectSerializer; * @param HeaderSelector $selector */ public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); @@ -93,8 +94,9 @@ use {{invokerPackage}}\ObjectSerializer; * @param {{dataType}} ${{paramName}}{{#description}} {{description}}{{/description}}{{^description}} {{paramName}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} {{/allParams}} * - * @throws \{{invokerPackage}}\ApiException on non-2xx response + * @throws \{{invokerPackage}}\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} */ public function {{operationId}}({{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}'{{{.}}}'{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) @@ -118,8 +120,9 @@ use {{invokerPackage}}\ObjectSerializer; * @param {{dataType}} ${{paramName}}{{#description}} {{description}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} {{/allParams}} * - * @throws \{{invokerPackage}}\ApiException on non-2xx response + * @throws \{{invokerPackage}}\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}null{{/returnType}}, HTTP status code, HTTP response headers (array of strings) */ public function {{operationId}}WithHttpInfo({{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}'{{{.}}}'{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) @@ -131,13 +134,17 @@ use {{invokerPackage}}\ObjectSerializer; $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -209,6 +216,7 @@ use {{invokerPackage}}\ObjectSerializer; {{/allParams}} * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function {{operationId}}Async({{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}'{{{.}}}'{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) @@ -235,6 +243,7 @@ use {{invokerPackage}}\ObjectSerializer; {{/allParams}} * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function {{operationId}}AsyncWithHttpInfo({{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}'{{{.}}}'{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) @@ -268,17 +277,23 @@ use {{invokerPackage}}\ObjectSerializer; {{/returnType}} }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -292,6 +307,7 @@ use {{invokerPackage}}\ObjectSerializer; {{/allParams}} * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function {{operationId}}Request({{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}'{{{.}}}'{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) @@ -396,7 +412,7 @@ use {{invokerPackage}}\ObjectSerializer; if (${{paramName}} !== null) { {{#isFile}} $multipart = true; - $formParams['{{baseName}}'] = \GuzzleHttp\Psr7\try_fopen(ObjectSerializer::toFormValue(${{paramName}}), 'rb'); + $formParams['{{baseName}}'] = \GuzzleHttp\Psr7\Utils::tryFopen(ObjectSerializer::toFormValue(${{paramName}}), 'rb'); {{/isFile}} {{^isFile}} $formParams['{{baseName}}'] = ObjectSerializer::toFormValue(${{paramName}}); @@ -430,11 +446,11 @@ use {{invokerPackage}}\ObjectSerializer; if($headers['Content-Type'] === 'application/json') { // \stdClass has no __toString(), so we should encode it manually if ($httpBody instanceof \stdClass) { - $httpBody = \GuzzleHttp\json_encode($httpBody); + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); } // array has no __toString(), so we should encode it manually if(is_array($httpBody)) { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); } } } elseif (count($formParams) > 0) { @@ -450,7 +466,7 @@ use {{invokerPackage}}\ObjectSerializer; $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) diff --git a/modules/swagger-codegen/src/main/resources/php/composer.mustache b/modules/swagger-codegen/src/main/resources/php/composer.mustache index 6f745a2c80d..c9b66bbb39c 100644 --- a/modules/swagger-codegen/src/main/resources/php/composer.mustache +++ b/modules/swagger-codegen/src/main/resources/php/composer.mustache @@ -19,16 +19,16 @@ } ], "require": { - "php": ">=5.5", + "php": ">=8.3", "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*", - "guzzlehttp/guzzle": "^6.2" + "guzzlehttp/guzzle": "^8.3" }, "require-dev": { - "phpunit/phpunit": "^8.5.52", - "squizlabs/php_codesniffer": "~2.6", - "friendsofphp/php-cs-fixer": "~2.12" + "phpunit/phpunit": "^9.6", + "squizlabs/php_codesniffer": "^3.0", + "friendsofphp/php-cs-fixer": "^3.0" }, "autoload": { "psr-4": { "{{escapedInvokerPackage}}\\" : "{{srcBasePath}}/" } diff --git a/modules/swagger-generator/pom.xml b/modules/swagger-generator/pom.xml index 3ec3339a39d..e87f75473b0 100644 --- a/modules/swagger-generator/pom.xml +++ b/modules/swagger-generator/pom.xml @@ -73,7 +73,7 @@ - ${project.build.directory}/swagger-ui-master/dist + ${project.build.directory}/swagger-ui-main/dist index.html @@ -144,7 +144,7 @@ wget - https://github.com/swagger-api/swagger-ui/archive/master.tar.gz + https://github.com/swagger-api/swagger-ui/archive/main.tar.gz true ${project.build.directory} diff --git a/samples/client/petstore-security-test/php/.swagger-codegen/VERSION b/samples/client/petstore-security-test/php/.swagger-codegen/VERSION index 855ff9501eb..bab531eaf33 100644 --- a/samples/client/petstore-security-test/php/.swagger-codegen/VERSION +++ b/samples/client/petstore-security-test/php/.swagger-codegen/VERSION @@ -1 +1 @@ -2.4.0-SNAPSHOT \ No newline at end of file +2.4.53-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/php/SwaggerClient-php/.php_cs b/samples/client/petstore-security-test/php/SwaggerClient-php/.php-cs-fixer.php similarity index 91% rename from samples/client/petstore/php/SwaggerClient-php/.php_cs rename to samples/client/petstore-security-test/php/SwaggerClient-php/.php-cs-fixer.php index 4fbe53ec5ff..dc702622b95 100644 --- a/samples/client/petstore/php/SwaggerClient-php/.php_cs +++ b/samples/client/petstore-security-test/php/SwaggerClient-php/.php-cs-fixer.php @@ -1,7 +1,8 @@ setUsingCache(true) + ->setRiskyAllowed(true) ->setRules([ '@PSR2' => true, 'ordered_imports' => true, diff --git a/samples/client/petstore-security-test/php/SwaggerClient-php/.php_cs b/samples/client/petstore-security-test/php/SwaggerClient-php/.php_cs deleted file mode 100644 index 6b8e23c818a..00000000000 --- a/samples/client/petstore-security-test/php/SwaggerClient-php/.php_cs +++ /dev/null @@ -1,18 +0,0 @@ -level(Symfony\CS\FixerInterface::PSR2_LEVEL) - ->setUsingCache(true) - ->fixers( - [ - 'ordered_use', - 'phpdoc_order', - 'short_array_syntax', - 'strict', - 'strict_param' - ] - ) - ->finder( - Symfony\CS\Finder\DefaultFinder::create() - ->in(__DIR__) - ); diff --git a/samples/client/petstore-security-test/php/SwaggerClient-php/.travis.yml b/samples/client/petstore-security-test/php/SwaggerClient-php/.travis.yml index d77f3825f6f..989be894218 100644 --- a/samples/client/petstore-security-test/php/SwaggerClient-php/.travis.yml +++ b/samples/client/petstore-security-test/php/SwaggerClient-php/.travis.yml @@ -1,10 +1,6 @@ language: php sudo: false php: - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - hhvm + - 8.3 before_install: "composer install" script: "vendor/bin/phpunit" 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 1f5c98d4da7..5c4b94e7d37 100644 --- a/samples/client/petstore-security-test/php/SwaggerClient-php/README.md +++ b/samples/client/petstore-security-test/php/SwaggerClient-php/README.md @@ -8,7 +8,7 @@ This PHP package is automatically generated by the [Swagger Codegen](https://git ## Requirements -PHP 5.5 and later +PHP 8.3 and later ## Installation & Usage ### Composer @@ -48,6 +48,8 @@ composer install ./vendor/bin/phpunit ``` +**Note:** Running tests requires PHP 8.3 or later. + ## Getting Started Please follow the [installation procedure](#installation--usage) and then run the following: diff --git a/samples/client/petstore-security-test/php/SwaggerClient-php/composer.json b/samples/client/petstore-security-test/php/SwaggerClient-php/composer.json index 2ebbe805eea..86b5a5cd12b 100644 --- a/samples/client/petstore-security-test/php/SwaggerClient-php/composer.json +++ b/samples/client/petstore-security-test/php/SwaggerClient-php/composer.json @@ -16,16 +16,16 @@ } ], "require": { - "php": ">=5.5", + "php": ">=8.3", "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*", - "guzzlehttp/guzzle": "^6.2" + "guzzlehttp/guzzle": "^8.3" }, "require-dev": { - "phpunit/phpunit": "^4.8", - "squizlabs/php_codesniffer": "~2.6", - "friendsofphp/php-cs-fixer": "~1.12" + "phpunit/phpunit": "^9.6", + "squizlabs/php_codesniffer": "^3.0", + "friendsofphp/php-cs-fixer": "^3.0" }, "autoload": { "psr-4": { "Swagger\\Client\\" : "lib/" } diff --git a/samples/client/petstore-security-test/php/SwaggerClient-php/git_push.sh b/samples/client/petstore-security-test/php/SwaggerClient-php/git_push.sh index 160f6f21399..ea15627ab9f 100644 --- a/samples/client/petstore-security-test/php/SwaggerClient-php/git_push.sh +++ b/samples/client/petstore-security-test/php/SwaggerClient-php/git_push.sh @@ -6,6 +6,7 @@ git_user_id=$1 git_repo_id=$2 release_note=$3 +git_repo_base_url=$4 if [ "$git_user_id" = "" ]; then git_user_id="GIT_USER_ID" @@ -22,6 +23,11 @@ if [ "$release_note" = "" ]; then echo "[INFO] No command line input provided. Set \$release_note to $release_note" fi +if [ "$git_repo_base_url" = "" ]; then + git_repo_base_url="https://github.com" + echo "[INFO] No command line input provided. Set \$git_repo_base_url to $git_repo_base_url" +fi + # Initialize the local directory as a Git repository git init @@ -37,9 +43,11 @@ if [ "$git_remote" = "" ]; then # git remote not defined if [ "$GIT_TOKEN" = "" ]; then echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." - git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + git remote add origin ${git_repo_base_url}/${git_user_id}/${git_repo_id}.git else - git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + git_repo_base_url=${git_repo_base_url#*//} + git_repo_base_url=${git_repo_base_url%%.*} + git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_repo_base_url}.com/${git_user_id}/${git_repo_id}.git fi fi @@ -47,6 +55,6 @@ fi git pull origin master # Pushes (Forces) the changes in the local repository up to the remote repository -echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +echo "Git pushing to https://${git_repo_base_url}.com/${git_user_id}/${git_repo_id}.git" git push origin master 2>&1 | grep -v 'To https' diff --git a/samples/client/petstore-security-test/php/SwaggerClient-php/lib/Api/FakeApi.php b/samples/client/petstore-security-test/php/SwaggerClient-php/lib/Api/FakeApi.php index 5f2eb0eff73..52c61afff2b 100644 --- a/samples/client/petstore-security-test/php/SwaggerClient-php/lib/Api/FakeApi.php +++ b/samples/client/petstore-security-test/php/SwaggerClient-php/lib/Api/FakeApi.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.0-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -30,7 +30,8 @@ use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\ResponseException; +use GuzzleHttp\Exception\TransferException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -70,9 +71,9 @@ class FakeApi * @param HeaderSelector $selector */ public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); @@ -94,8 +95,9 @@ public function getConfig() * * @param string $test_code_inject____end____rn_n_r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return void */ public function testCodeInjectEndRnNR($test_code_inject____end____rn_n_r = null) @@ -110,8 +112,9 @@ public function testCodeInjectEndRnNR($test_code_inject____end____rn_n_r = null) * * @param string $test_code_inject____end____rn_n_r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ public function testCodeInjectEndRnNRWithHttpInfo($test_code_inject____end____rn_n_r = null) @@ -123,13 +126,17 @@ public function testCodeInjectEndRnNRWithHttpInfo($test_code_inject____end____rn $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -164,6 +171,7 @@ public function testCodeInjectEndRnNRWithHttpInfo($test_code_inject____end____rn * @param string $test_code_inject____end____rn_n_r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function testCodeInjectEndRnNRAsync($test_code_inject____end____rn_n_r = null) @@ -184,6 +192,7 @@ function ($response) { * @param string $test_code_inject____end____rn_n_r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function testCodeInjectEndRnNRAsyncWithHttpInfo($test_code_inject____end____rn_n_r = null) @@ -198,17 +207,23 @@ function ($response) use ($returnType) { return [null, $response->getStatusCode(), $response->getHeaders()]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -220,6 +235,7 @@ function ($exception) { * @param string $test_code_inject____end____rn_n_r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function testCodeInjectEndRnNRRequest($test_code_inject____end____rn_n_r = null) @@ -256,9 +272,16 @@ protected function testCodeInjectEndRnNRRequest($test_code_inject____end____rn_n if (isset($_tempBody)) { // $_tempBody is the method argument, if present $httpBody = $_tempBody; - // \stdClass has no __toString(), so we should encode it manually - if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($httpBody); + + if($headers['Content-Type'] === 'application/json') { + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass) { + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); + } + // array has no __toString(), so we should encode it manually + if(is_array($httpBody)) { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); + } } } elseif (count($formParams) > 0) { if ($multipart) { @@ -273,7 +296,7 @@ protected function testCodeInjectEndRnNRRequest($test_code_inject____end____rn_n $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) diff --git a/samples/client/petstore-security-test/php/SwaggerClient-php/lib/ApiException.php b/samples/client/petstore-security-test/php/SwaggerClient-php/lib/ApiException.php index 9ed326a3c6f..df4ede95c14 100644 --- a/samples/client/petstore-security-test/php/SwaggerClient-php/lib/ApiException.php +++ b/samples/client/petstore-security-test/php/SwaggerClient-php/lib/ApiException.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.0-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** diff --git a/samples/client/petstore-security-test/php/SwaggerClient-php/lib/Configuration.php b/samples/client/petstore-security-test/php/SwaggerClient-php/lib/Configuration.php index 192e8b2c6c7..7977daf0e1a 100644 --- a/samples/client/petstore-security-test/php/SwaggerClient-php/lib/Configuration.php +++ b/samples/client/petstore-security-test/php/SwaggerClient-php/lib/Configuration.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.0-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** diff --git a/samples/client/petstore-security-test/php/SwaggerClient-php/lib/HeaderSelector.php b/samples/client/petstore-security-test/php/SwaggerClient-php/lib/HeaderSelector.php index 676173de468..a19fc4e2eeb 100644 --- a/samples/client/petstore-security-test/php/SwaggerClient-php/lib/HeaderSelector.php +++ b/samples/client/petstore-security-test/php/SwaggerClient-php/lib/HeaderSelector.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.0-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -107,4 +107,3 @@ private function selectContentTypeHeader($contentType) } } } - diff --git a/samples/client/petstore-security-test/php/SwaggerClient-php/lib/Model/ModelInterface.php b/samples/client/petstore-security-test/php/SwaggerClient-php/lib/Model/ModelInterface.php index 6013c8cf977..2232a898a2e 100644 --- a/samples/client/petstore-security-test/php/SwaggerClient-php/lib/Model/ModelInterface.php +++ b/samples/client/petstore-security-test/php/SwaggerClient-php/lib/Model/ModelInterface.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.0-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** diff --git a/samples/client/petstore-security-test/php/SwaggerClient-php/lib/Model/ModelReturn.php b/samples/client/petstore-security-test/php/SwaggerClient-php/lib/Model/ModelReturn.php index 4d820c4cc87..ec1e50639ca 100644 --- a/samples/client/petstore-security-test/php/SwaggerClient-php/lib/Model/ModelReturn.php +++ b/samples/client/petstore-security-test/php/SwaggerClient-php/lib/Model/ModelReturn.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.0-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -235,6 +235,7 @@ public function setReturn($return) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -247,6 +248,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -260,6 +262,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -276,6 +279,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore-security-test/php/SwaggerClient-php/lib/ObjectSerializer.php b/samples/client/petstore-security-test/php/SwaggerClient-php/lib/ObjectSerializer.php index 720eb97a8e5..85d32a9d239 100644 --- a/samples/client/petstore-security-test/php/SwaggerClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore-security-test/php/SwaggerClient-php/lib/ObjectSerializer.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.0-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -59,6 +59,11 @@ public static function sanitizeForSerialization($data, $type = null, $format = n $data[$property] = self::sanitizeForSerialization($value); } return $data; + } elseif ($data instanceof \stdClass) { + foreach ($data as $property => $value) { + $data->$property = self::sanitizeForSerialization($value); + } + return $data; } elseif (is_object($data)) { $values = []; $formats = $data::swaggerFormats(); @@ -68,7 +73,7 @@ public static function sanitizeForSerialization($data, $type = null, $format = n if ($value !== null && !in_array($swaggerType, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true) && method_exists($swaggerType, 'getAllowableEnumValues') - && !in_array($value, $swaggerType::getAllowableEnumValues())) { + && !in_array($value, $swaggerType::getAllowableEnumValues(), true)) { $imploded = implode("', '", $swaggerType::getAllowableEnumValues()); throw new \InvalidArgumentException("Invalid value for enum '$swaggerType', must be one of: '$imploded'"); } @@ -284,7 +289,7 @@ public static function deserialize($data, $class, $httpHeaders = null) return new \SplFileObject($filename, 'r'); } elseif (method_exists($class, 'getAllowableEnumValues')) { - if (!in_array($data, $class::getAllowableEnumValues())) { + if (!in_array($data, $class::getAllowableEnumValues(), true)) { $imploded = implode("', '", $class::getAllowableEnumValues()); throw new \InvalidArgumentException("Invalid value for enum '$class', must be one of: '$imploded'"); } diff --git a/samples/client/petstore-security-test/php/SwaggerClient-php/test/Api/FakeApiTest.php b/samples/client/petstore-security-test/php/SwaggerClient-php/test/Api/FakeApiTest.php index 613e83d2089..f51f3f469b6 100644 --- a/samples/client/petstore-security-test/php/SwaggerClient-php/test/Api/FakeApiTest.php +++ b/samples/client/petstore-security-test/php/SwaggerClient-php/test/Api/FakeApiTest.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.0-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -40,34 +40,34 @@ * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen */ -class FakeApiTest extends \PHPUnit_Framework_TestCase +class FakeApiTest extends \PHPUnit\Framework\TestCase { /** * Setup before running any test cases */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { } /** * Setup before running each test case */ - public function setUp() + public function setUp(): void { } /** * Clean up after running each test case */ - public function tearDown() + public function tearDown(): void { } /** * Clean up after running all test cases */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { } diff --git a/samples/client/petstore-security-test/php/SwaggerClient-php/test/Model/ModelReturnTest.php b/samples/client/petstore-security-test/php/SwaggerClient-php/test/Model/ModelReturnTest.php index b49dc30a4e0..8543abdcf08 100644 --- a/samples/client/petstore-security-test/php/SwaggerClient-php/test/Model/ModelReturnTest.php +++ b/samples/client/petstore-security-test/php/SwaggerClient-php/test/Model/ModelReturnTest.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.0-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -38,34 +38,34 @@ * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen */ -class ModelReturnTest extends \PHPUnit_Framework_TestCase +class ModelReturnTest extends \PHPUnit\Framework\TestCase { /** * Setup before running any test case */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { } /** * Setup before running each test case */ - public function setUp() + public function setUp(): void { } /** * Clean up after running each test case */ - public function tearDown() + public function tearDown(): void { } /** * Clean up after running all test cases */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { } diff --git a/samples/client/petstore/php/.swagger-codegen/VERSION b/samples/client/petstore/php/.swagger-codegen/VERSION index 017674fb59d..bab531eaf33 100644 --- a/samples/client/petstore/php/.swagger-codegen/VERSION +++ b/samples/client/petstore/php/.swagger-codegen/VERSION @@ -1 +1 @@ -2.4.3-SNAPSHOT \ No newline at end of file +2.4.53-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/php/SwaggerClient-php/.php-cs-fixer.php b/samples/client/petstore/php/SwaggerClient-php/.php-cs-fixer.php new file mode 100644 index 00000000000..dc702622b95 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/.php-cs-fixer.php @@ -0,0 +1,24 @@ +setUsingCache(true) + ->setRiskyAllowed(true) + ->setRules([ + '@PSR2' => true, + 'ordered_imports' => true, + 'phpdoc_order' => true, + 'array_syntax' => [ 'syntax' => 'short' ], + 'strict_comparison' => true, + 'strict_param' => true, + 'no_trailing_whitespace' => false, + 'no_trailing_whitespace_in_comment' => false, + 'braces' => false, + 'single_blank_line_at_eof' => false, + 'blank_line_after_namespace' => false, + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('test') + ->exclude('tests') + ->in(__DIR__) + ); diff --git a/samples/client/petstore/php/SwaggerClient-php/.travis.yml b/samples/client/petstore/php/SwaggerClient-php/.travis.yml index d77f3825f6f..989be894218 100644 --- a/samples/client/petstore/php/SwaggerClient-php/.travis.yml +++ b/samples/client/petstore/php/SwaggerClient-php/.travis.yml @@ -1,10 +1,6 @@ language: php sudo: false php: - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - hhvm + - 8.3 before_install: "composer install" script: "vendor/bin/phpunit" diff --git a/samples/client/petstore/php/SwaggerClient-php/README.md b/samples/client/petstore/php/SwaggerClient-php/README.md index feba5d37b72..1267a0ff3ef 100644 --- a/samples/client/petstore/php/SwaggerClient-php/README.md +++ b/samples/client/petstore/php/SwaggerClient-php/README.md @@ -1,5 +1,5 @@ # SwaggerClient-php -This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ This PHP package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: @@ -8,7 +8,7 @@ This PHP package is automatically generated by the [Swagger Codegen](https://git ## Requirements -PHP 5.5 and later +PHP 8.3 and later ## Installation & Usage ### Composer @@ -48,6 +48,8 @@ composer install ./vendor/bin/phpunit ``` +**Note:** Running tests requires PHP 8.3 or later. + ## Getting Started Please follow the [installation procedure](#installation--usage) and then run the following: @@ -56,21 +58,18 @@ Please follow the [installation procedure](#installation--usage) and then run th setAccessToken('YOUR_ACCESS_TOKEN'); - -$apiInstance = new Swagger\Client\Api\PetApi( +$apiInstance = new Swagger\Client\Api\AnotherFakeApi( // 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 + new GuzzleHttp\Client() ); -$body = new \Swagger\Client\Model\Pet(); // \Swagger\Client\Model\Pet | Pet object that needs to be added to the store +$body = new \Swagger\Client\Model\Client(); // \Swagger\Client\Model\Client | client model try { - $apiInstance->addPet($body); + $result = $apiInstance->testSpecialTags($body); + print_r($result); } catch (Exception $e) { - echo 'Exception when calling PetApi->addPet: ', $e->getMessage(), PHP_EOL; + echo 'Exception when calling AnotherFakeApi->testSpecialTags: ', $e->getMessage(), PHP_EOL; } ?> @@ -78,10 +77,22 @@ try { ## Documentation for API Endpoints -All URIs are relative to *http://petstore.swagger.io/v2* +All URIs are relative to *http://petstore.swagger.io:80/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- +*AnotherFakeApi* | [**testSpecialTags**](docs/Api/AnotherFakeApi.md#testspecialtags) | **PATCH** /another-fake/dummy | To test special tags +*FakeApi* | [**fakeOuterBooleanSerialize**](docs/Api/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean | +*FakeApi* | [**fakeOuterCompositeSerialize**](docs/Api/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite | +*FakeApi* | [**fakeOuterNumberSerialize**](docs/Api/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | +*FakeApi* | [**fakeOuterStringSerialize**](docs/Api/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | +*FakeApi* | [**testBodyWithQueryParams**](docs/Api/FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | +*FakeApi* | [**testClientModel**](docs/Api/FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model +*FakeApi* | [**testEndpointParameters**](docs/Api/FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +*FakeApi* | [**testEnumParameters**](docs/Api/FakeApi.md#testenumparameters) | **GET** /fake | To test enum parameters +*FakeApi* | [**testInlineAdditionalProperties**](docs/Api/FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties +*FakeApi* | [**testJsonFormData**](docs/Api/FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeClassnameTags123Api* | [**testClassname**](docs/Api/FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**addPet**](docs/Api/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store *PetApi* | [**deletePet**](docs/Api/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet *PetApi* | [**findPetsByStatus**](docs/Api/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status @@ -90,9 +101,9 @@ Class | Method | HTTP request | Description *PetApi* | [**updatePet**](docs/Api/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet *PetApi* | [**updatePetWithForm**](docs/Api/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data *PetApi* | [**uploadFile**](docs/Api/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image -*StoreApi* | [**deleteOrder**](docs/Api/StoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**deleteOrder**](docs/Api/StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID *StoreApi* | [**getInventory**](docs/Api/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status -*StoreApi* | [**getOrderById**](docs/Api/StoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**getOrderById**](docs/Api/StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID *StoreApi* | [**placeOrder**](docs/Api/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet *UserApi* | [**createUser**](docs/Api/UserApi.md#createuser) | **POST** /user | Create user *UserApi* | [**createUsersWithArrayInput**](docs/Api/UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array @@ -106,10 +117,41 @@ Class | Method | HTTP request | Description ## Documentation For Models + - [AdditionalPropertiesClass](docs/Model/AdditionalPropertiesClass.md) + - [Animal](docs/Model/Animal.md) + - [AnimalFarm](docs/Model/AnimalFarm.md) - [ApiResponse](docs/Model/ApiResponse.md) + - [ArrayOfArrayOfNumberOnly](docs/Model/ArrayOfArrayOfNumberOnly.md) + - [ArrayOfNumberOnly](docs/Model/ArrayOfNumberOnly.md) + - [ArrayTest](docs/Model/ArrayTest.md) + - [Boolean](docs/Model/Boolean.md) + - [Capitalization](docs/Model/Capitalization.md) + - [Cat](docs/Model/Cat.md) - [Category](docs/Model/Category.md) + - [ClassModel](docs/Model/ClassModel.md) + - [Client](docs/Model/Client.md) + - [Dog](docs/Model/Dog.md) + - [EnumArrays](docs/Model/EnumArrays.md) + - [EnumClass](docs/Model/EnumClass.md) + - [EnumTest](docs/Model/EnumTest.md) + - [FormatTest](docs/Model/FormatTest.md) + - [HasOnlyReadOnly](docs/Model/HasOnlyReadOnly.md) + - [MapTest](docs/Model/MapTest.md) + - [MixedPropertiesAndAdditionalPropertiesClass](docs/Model/MixedPropertiesAndAdditionalPropertiesClass.md) + - [Model200Response](docs/Model/Model200Response.md) + - [ModelList](docs/Model/ModelList.md) + - [ModelReturn](docs/Model/ModelReturn.md) + - [Name](docs/Model/Name.md) + - [NumberOnly](docs/Model/NumberOnly.md) - [Order](docs/Model/Order.md) + - [OuterBoolean](docs/Model/OuterBoolean.md) + - [OuterComposite](docs/Model/OuterComposite.md) + - [OuterEnum](docs/Model/OuterEnum.md) + - [OuterNumber](docs/Model/OuterNumber.md) + - [OuterString](docs/Model/OuterString.md) - [Pet](docs/Model/Pet.md) + - [ReadOnlyFirst](docs/Model/ReadOnlyFirst.md) + - [SpecialModelName](docs/Model/SpecialModelName.md) - [Tag](docs/Model/Tag.md) - [User](docs/Model/User.md) @@ -123,6 +165,16 @@ Class | Method | HTTP request | Description - **API key parameter name**: api_key - **Location**: HTTP header +## api_key_query + +- **Type**: API key +- **API key parameter name**: api_key_query +- **Location**: URL query string + +## http_basic_test + +- **Type**: HTTP basic authentication + ## petstore_auth - **Type**: OAuth diff --git a/samples/client/petstore/php/SwaggerClient-php/composer.json b/samples/client/petstore/php/SwaggerClient-php/composer.json index 2d76f02819b..86b5a5cd12b 100644 --- a/samples/client/petstore/php/SwaggerClient-php/composer.json +++ b/samples/client/petstore/php/SwaggerClient-php/composer.json @@ -16,16 +16,16 @@ } ], "require": { - "php": ">=5.5", + "php": ">=8.3", "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*", - "guzzlehttp/guzzle": "^6.2" + "guzzlehttp/guzzle": "^8.3" }, "require-dev": { - "phpunit/phpunit": "^4.8", - "squizlabs/php_codesniffer": "~2.6", - "friendsofphp/php-cs-fixer": "~2.12" + "phpunit/phpunit": "^9.6", + "squizlabs/php_codesniffer": "^3.0", + "friendsofphp/php-cs-fixer": "^3.0" }, "autoload": { "psr-4": { "Swagger\\Client\\" : "lib/" } 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 6a1773d4b28..46e42007fac 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Api/PetApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Api/PetApi.md @@ -1,6 +1,6 @@ # Swagger\Client\PetApi -All URIs are relative to *http://petstore.swagger.io/v2* +All URIs are relative to *http://petstore.swagger.io:80/v2* Method | HTTP request | Description ------------- | ------------- | ------------- 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 649dcc4b265..87cec61aa7b 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Api/StoreApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Api/StoreApi.md @@ -1,12 +1,12 @@ # Swagger\Client\StoreApi -All URIs are relative to *http://petstore.swagger.io/v2* +All URIs are relative to *http://petstore.swagger.io:80/v2* Method | HTTP request | Description ------------- | ------------- | ------------- -[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID [**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status -[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID +[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{order_id} | Find purchase order by ID [**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet 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 7953ca871f6..52b0a351904 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Api/UserApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Api/UserApi.md @@ -1,6 +1,6 @@ # Swagger\Client\UserApi -All URIs are relative to *http://petstore.swagger.io/v2* +All URIs are relative to *http://petstore.swagger.io:80/v2* Method | HTTP request | Description ------------- | ------------- | ------------- diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Model/Boolean.md b/samples/client/petstore/php/SwaggerClient-php/docs/Model/Boolean.md new file mode 100644 index 00000000000..d0b536f8086 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Model/Boolean.md @@ -0,0 +1,9 @@ +# Boolean + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/SwaggerClient-php/git_push.sh b/samples/client/petstore/php/SwaggerClient-php/git_push.sh index 160f6f21399..ea15627ab9f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/git_push.sh +++ b/samples/client/petstore/php/SwaggerClient-php/git_push.sh @@ -6,6 +6,7 @@ git_user_id=$1 git_repo_id=$2 release_note=$3 +git_repo_base_url=$4 if [ "$git_user_id" = "" ]; then git_user_id="GIT_USER_ID" @@ -22,6 +23,11 @@ if [ "$release_note" = "" ]; then echo "[INFO] No command line input provided. Set \$release_note to $release_note" fi +if [ "$git_repo_base_url" = "" ]; then + git_repo_base_url="https://github.com" + echo "[INFO] No command line input provided. Set \$git_repo_base_url to $git_repo_base_url" +fi + # Initialize the local directory as a Git repository git init @@ -37,9 +43,11 @@ if [ "$git_remote" = "" ]; then # git remote not defined if [ "$GIT_TOKEN" = "" ]; then echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." - git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + git remote add origin ${git_repo_base_url}/${git_user_id}/${git_repo_id}.git else - git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + git_repo_base_url=${git_repo_base_url#*//} + git_repo_base_url=${git_repo_base_url%%.*} + git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_repo_base_url}.com/${git_user_id}/${git_repo_id}.git fi fi @@ -47,6 +55,6 @@ fi git pull origin master # Pushes (Forces) the changes in the local repository up to the remote repository -echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +echo "Git pushing to https://${git_repo_base_url}.com/${git_user_id}/${git_repo_id}.git" git push origin master 2>&1 | grep -v 'To https' diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/AnotherFakeApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/AnotherFakeApi.php index c54892b41b3..f4ccb16b2f9 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/AnotherFakeApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/AnotherFakeApi.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -30,7 +30,8 @@ use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\ResponseException; +use GuzzleHttp\Exception\TransferException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -70,9 +71,9 @@ class AnotherFakeApi * @param HeaderSelector $selector */ public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); @@ -94,8 +95,9 @@ public function getConfig() * * @param \Swagger\Client\Model\Client $body client model (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return \Swagger\Client\Model\Client */ public function testSpecialTags($body) @@ -111,8 +113,9 @@ public function testSpecialTags($body) * * @param \Swagger\Client\Model\Client $body client model (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of \Swagger\Client\Model\Client, HTTP status code, HTTP response headers (array of strings) */ public function testSpecialTagsWithHttpInfo($body) @@ -124,13 +127,17 @@ public function testSpecialTagsWithHttpInfo($body) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -187,6 +194,7 @@ public function testSpecialTagsWithHttpInfo($body) * @param \Swagger\Client\Model\Client $body client model (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function testSpecialTagsAsync($body) @@ -207,6 +215,7 @@ function ($response) { * @param \Swagger\Client\Model\Client $body client model (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function testSpecialTagsAsyncWithHttpInfo($body) @@ -235,17 +244,23 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -257,6 +272,7 @@ function ($exception) { * @param \Swagger\Client\Model\Client $body client model (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function testSpecialTagsRequest($body) @@ -298,9 +314,16 @@ protected function testSpecialTagsRequest($body) if (isset($_tempBody)) { // $_tempBody is the method argument, if present $httpBody = $_tempBody; - // \stdClass has no __toString(), so we should encode it manually - if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($httpBody); + + if($headers['Content-Type'] === 'application/json') { + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass) { + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); + } + // array has no __toString(), so we should encode it manually + if(is_array($httpBody)) { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); + } } } elseif (count($formParams) > 0) { if ($multipart) { @@ -315,7 +338,7 @@ protected function testSpecialTagsRequest($body) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/FakeApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/FakeApi.php index db1172f6ccc..c479a8e2fd2 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/FakeApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/FakeApi.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -30,7 +30,8 @@ use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\ResponseException; +use GuzzleHttp\Exception\TransferException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -70,9 +71,9 @@ class FakeApi * @param HeaderSelector $selector */ public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); @@ -92,8 +93,9 @@ public function getConfig() * * @param \Swagger\Client\Model\OuterBoolean $body Input boolean as post body (optional) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return \Swagger\Client\Model\OuterBoolean */ public function fakeOuterBooleanSerialize($body = null) @@ -107,8 +109,9 @@ public function fakeOuterBooleanSerialize($body = null) * * @param \Swagger\Client\Model\OuterBoolean $body Input boolean as post body (optional) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of \Swagger\Client\Model\OuterBoolean, HTTP status code, HTTP response headers (array of strings) */ public function fakeOuterBooleanSerializeWithHttpInfo($body = null) @@ -120,13 +123,17 @@ public function fakeOuterBooleanSerializeWithHttpInfo($body = null) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -183,6 +190,7 @@ public function fakeOuterBooleanSerializeWithHttpInfo($body = null) * @param \Swagger\Client\Model\OuterBoolean $body Input boolean as post body (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function fakeOuterBooleanSerializeAsync($body = null) @@ -203,6 +211,7 @@ function ($response) { * @param \Swagger\Client\Model\OuterBoolean $body Input boolean as post body (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function fakeOuterBooleanSerializeAsyncWithHttpInfo($body = null) @@ -231,17 +240,23 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -253,6 +268,7 @@ function ($exception) { * @param \Swagger\Client\Model\OuterBoolean $body Input boolean as post body (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function fakeOuterBooleanSerializeRequest($body = null) @@ -288,9 +304,16 @@ protected function fakeOuterBooleanSerializeRequest($body = null) if (isset($_tempBody)) { // $_tempBody is the method argument, if present $httpBody = $_tempBody; - // \stdClass has no __toString(), so we should encode it manually - if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($httpBody); + + if($headers['Content-Type'] === 'application/json') { + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass) { + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); + } + // array has no __toString(), so we should encode it manually + if(is_array($httpBody)) { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); + } } } elseif (count($formParams) > 0) { if ($multipart) { @@ -305,7 +328,7 @@ protected function fakeOuterBooleanSerializeRequest($body = null) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -339,8 +362,9 @@ protected function fakeOuterBooleanSerializeRequest($body = null) * * @param \Swagger\Client\Model\OuterComposite $body Input composite as post body (optional) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return \Swagger\Client\Model\OuterComposite */ public function fakeOuterCompositeSerialize($body = null) @@ -354,8 +378,9 @@ public function fakeOuterCompositeSerialize($body = null) * * @param \Swagger\Client\Model\OuterComposite $body Input composite as post body (optional) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of \Swagger\Client\Model\OuterComposite, HTTP status code, HTTP response headers (array of strings) */ public function fakeOuterCompositeSerializeWithHttpInfo($body = null) @@ -367,13 +392,17 @@ public function fakeOuterCompositeSerializeWithHttpInfo($body = null) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -430,6 +459,7 @@ public function fakeOuterCompositeSerializeWithHttpInfo($body = null) * @param \Swagger\Client\Model\OuterComposite $body Input composite as post body (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function fakeOuterCompositeSerializeAsync($body = null) @@ -450,6 +480,7 @@ function ($response) { * @param \Swagger\Client\Model\OuterComposite $body Input composite as post body (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function fakeOuterCompositeSerializeAsyncWithHttpInfo($body = null) @@ -478,17 +509,23 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -500,6 +537,7 @@ function ($exception) { * @param \Swagger\Client\Model\OuterComposite $body Input composite as post body (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function fakeOuterCompositeSerializeRequest($body = null) @@ -535,9 +573,16 @@ protected function fakeOuterCompositeSerializeRequest($body = null) if (isset($_tempBody)) { // $_tempBody is the method argument, if present $httpBody = $_tempBody; - // \stdClass has no __toString(), so we should encode it manually - if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($httpBody); + + if($headers['Content-Type'] === 'application/json') { + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass) { + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); + } + // array has no __toString(), so we should encode it manually + if(is_array($httpBody)) { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); + } } } elseif (count($formParams) > 0) { if ($multipart) { @@ -552,7 +597,7 @@ protected function fakeOuterCompositeSerializeRequest($body = null) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -586,8 +631,9 @@ protected function fakeOuterCompositeSerializeRequest($body = null) * * @param \Swagger\Client\Model\OuterNumber $body Input number as post body (optional) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return \Swagger\Client\Model\OuterNumber */ public function fakeOuterNumberSerialize($body = null) @@ -601,8 +647,9 @@ public function fakeOuterNumberSerialize($body = null) * * @param \Swagger\Client\Model\OuterNumber $body Input number as post body (optional) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of \Swagger\Client\Model\OuterNumber, HTTP status code, HTTP response headers (array of strings) */ public function fakeOuterNumberSerializeWithHttpInfo($body = null) @@ -614,13 +661,17 @@ public function fakeOuterNumberSerializeWithHttpInfo($body = null) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -677,6 +728,7 @@ public function fakeOuterNumberSerializeWithHttpInfo($body = null) * @param \Swagger\Client\Model\OuterNumber $body Input number as post body (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function fakeOuterNumberSerializeAsync($body = null) @@ -697,6 +749,7 @@ function ($response) { * @param \Swagger\Client\Model\OuterNumber $body Input number as post body (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function fakeOuterNumberSerializeAsyncWithHttpInfo($body = null) @@ -725,17 +778,23 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -747,6 +806,7 @@ function ($exception) { * @param \Swagger\Client\Model\OuterNumber $body Input number as post body (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function fakeOuterNumberSerializeRequest($body = null) @@ -782,9 +842,16 @@ protected function fakeOuterNumberSerializeRequest($body = null) if (isset($_tempBody)) { // $_tempBody is the method argument, if present $httpBody = $_tempBody; - // \stdClass has no __toString(), so we should encode it manually - if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($httpBody); + + if($headers['Content-Type'] === 'application/json') { + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass) { + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); + } + // array has no __toString(), so we should encode it manually + if(is_array($httpBody)) { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); + } } } elseif (count($formParams) > 0) { if ($multipart) { @@ -799,7 +866,7 @@ protected function fakeOuterNumberSerializeRequest($body = null) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -833,8 +900,9 @@ protected function fakeOuterNumberSerializeRequest($body = null) * * @param \Swagger\Client\Model\OuterString $body Input string as post body (optional) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return \Swagger\Client\Model\OuterString */ public function fakeOuterStringSerialize($body = null) @@ -848,8 +916,9 @@ public function fakeOuterStringSerialize($body = null) * * @param \Swagger\Client\Model\OuterString $body Input string as post body (optional) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of \Swagger\Client\Model\OuterString, HTTP status code, HTTP response headers (array of strings) */ public function fakeOuterStringSerializeWithHttpInfo($body = null) @@ -861,13 +930,17 @@ public function fakeOuterStringSerializeWithHttpInfo($body = null) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -924,6 +997,7 @@ public function fakeOuterStringSerializeWithHttpInfo($body = null) * @param \Swagger\Client\Model\OuterString $body Input string as post body (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function fakeOuterStringSerializeAsync($body = null) @@ -944,6 +1018,7 @@ function ($response) { * @param \Swagger\Client\Model\OuterString $body Input string as post body (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function fakeOuterStringSerializeAsyncWithHttpInfo($body = null) @@ -972,17 +1047,23 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -994,6 +1075,7 @@ function ($exception) { * @param \Swagger\Client\Model\OuterString $body Input string as post body (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function fakeOuterStringSerializeRequest($body = null) @@ -1029,9 +1111,16 @@ protected function fakeOuterStringSerializeRequest($body = null) if (isset($_tempBody)) { // $_tempBody is the method argument, if present $httpBody = $_tempBody; - // \stdClass has no __toString(), so we should encode it manually - if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($httpBody); + + if($headers['Content-Type'] === 'application/json') { + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass) { + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); + } + // array has no __toString(), so we should encode it manually + if(is_array($httpBody)) { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); + } } } elseif (count($formParams) > 0) { if ($multipart) { @@ -1046,7 +1135,7 @@ protected function fakeOuterStringSerializeRequest($body = null) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -1081,8 +1170,9 @@ protected function fakeOuterStringSerializeRequest($body = null) * @param \Swagger\Client\Model\User $body body (required) * @param string $query query (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return void */ public function testBodyWithQueryParams($body, $query) @@ -1096,8 +1186,9 @@ public function testBodyWithQueryParams($body, $query) * @param \Swagger\Client\Model\User $body (required) * @param string $query (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ public function testBodyWithQueryParamsWithHttpInfo($body, $query) @@ -1109,13 +1200,17 @@ public function testBodyWithQueryParamsWithHttpInfo($body, $query) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -1151,6 +1246,7 @@ public function testBodyWithQueryParamsWithHttpInfo($body, $query) * @param string $query (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function testBodyWithQueryParamsAsync($body, $query) @@ -1172,6 +1268,7 @@ function ($response) { * @param string $query (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function testBodyWithQueryParamsAsyncWithHttpInfo($body, $query) @@ -1186,17 +1283,23 @@ function ($response) use ($returnType) { return [null, $response->getStatusCode(), $response->getHeaders()]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -1209,6 +1312,7 @@ function ($exception) { * @param string $query (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function testBodyWithQueryParamsRequest($body, $query) @@ -1260,9 +1364,16 @@ protected function testBodyWithQueryParamsRequest($body, $query) if (isset($_tempBody)) { // $_tempBody is the method argument, if present $httpBody = $_tempBody; - // \stdClass has no __toString(), so we should encode it manually - if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($httpBody); + + if($headers['Content-Type'] === 'application/json') { + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass) { + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); + } + // array has no __toString(), so we should encode it manually + if(is_array($httpBody)) { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); + } } } elseif (count($formParams) > 0) { if ($multipart) { @@ -1277,7 +1388,7 @@ protected function testBodyWithQueryParamsRequest($body, $query) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -1313,8 +1424,9 @@ protected function testBodyWithQueryParamsRequest($body, $query) * * @param \Swagger\Client\Model\Client $body client model (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return \Swagger\Client\Model\Client */ public function testClientModel($body) @@ -1330,8 +1442,9 @@ public function testClientModel($body) * * @param \Swagger\Client\Model\Client $body client model (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of \Swagger\Client\Model\Client, HTTP status code, HTTP response headers (array of strings) */ public function testClientModelWithHttpInfo($body) @@ -1343,13 +1456,17 @@ public function testClientModelWithHttpInfo($body) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -1406,6 +1523,7 @@ public function testClientModelWithHttpInfo($body) * @param \Swagger\Client\Model\Client $body client model (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function testClientModelAsync($body) @@ -1426,6 +1544,7 @@ function ($response) { * @param \Swagger\Client\Model\Client $body client model (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function testClientModelAsyncWithHttpInfo($body) @@ -1454,17 +1573,23 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -1476,6 +1601,7 @@ function ($exception) { * @param \Swagger\Client\Model\Client $body client model (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function testClientModelRequest($body) @@ -1517,9 +1643,16 @@ protected function testClientModelRequest($body) if (isset($_tempBody)) { // $_tempBody is the method argument, if present $httpBody = $_tempBody; - // \stdClass has no __toString(), so we should encode it manually - if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($httpBody); + + if($headers['Content-Type'] === 'application/json') { + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass) { + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); + } + // array has no __toString(), so we should encode it manually + if(is_array($httpBody)) { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); + } } } elseif (count($formParams) > 0) { if ($multipart) { @@ -1534,7 +1667,7 @@ protected function testClientModelRequest($body) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -1583,8 +1716,9 @@ protected function testClientModelRequest($body) * @param string $password None (optional) * @param string $callback None (optional) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return void */ public function testEndpointParameters($number, $double, $pattern_without_delimiter, $byte, $integer = null, $int32 = null, $int64 = null, $float = null, $string = null, $binary = null, $date = null, $date_time = null, $password = null, $callback = null) @@ -1612,8 +1746,9 @@ public function testEndpointParameters($number, $double, $pattern_without_delimi * @param string $password None (optional) * @param string $callback None (optional) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ public function testEndpointParametersWithHttpInfo($number, $double, $pattern_without_delimiter, $byte, $integer = null, $int32 = null, $int64 = null, $float = null, $string = null, $binary = null, $date = null, $date_time = null, $password = null, $callback = null) @@ -1625,13 +1760,17 @@ public function testEndpointParametersWithHttpInfo($number, $double, $pattern_wi $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -1679,6 +1818,7 @@ public function testEndpointParametersWithHttpInfo($number, $double, $pattern_wi * @param string $callback None (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function testEndpointParametersAsync($number, $double, $pattern_without_delimiter, $byte, $integer = null, $int32 = null, $int64 = null, $float = null, $string = null, $binary = null, $date = null, $date_time = null, $password = null, $callback = null) @@ -1712,6 +1852,7 @@ function ($response) { * @param string $callback None (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function testEndpointParametersAsyncWithHttpInfo($number, $double, $pattern_without_delimiter, $byte, $integer = null, $int32 = null, $int64 = null, $float = null, $string = null, $binary = null, $date = null, $date_time = null, $password = null, $callback = null) @@ -1726,17 +1867,23 @@ function ($response) use ($returnType) { return [null, $response->getStatusCode(), $response->getHeaders()]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -1761,6 +1908,7 @@ function ($exception) { * @param string $callback None (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function testEndpointParametersRequest($number, $double, $pattern_without_delimiter, $byte, $integer = null, $int32 = null, $int64 = null, $float = null, $string = null, $binary = null, $date = null, $date_time = null, $password = null, $callback = null) @@ -1920,9 +2068,16 @@ protected function testEndpointParametersRequest($number, $double, $pattern_with if (isset($_tempBody)) { // $_tempBody is the method argument, if present $httpBody = $_tempBody; - // \stdClass has no __toString(), so we should encode it manually - if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($httpBody); + + if($headers['Content-Type'] === 'application/json') { + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass) { + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); + } + // array has no __toString(), so we should encode it manually + if(is_array($httpBody)) { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); + } } } elseif (count($formParams) > 0) { if ($multipart) { @@ -1937,7 +2092,7 @@ protected function testEndpointParametersRequest($number, $double, $pattern_with $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -1984,8 +2139,9 @@ protected function testEndpointParametersRequest($number, $double, $pattern_with * @param int $enum_query_integer Query parameter enum test (double) (optional) * @param double $enum_query_double Query parameter enum test (double) (optional) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return void */ public function testEnumParameters($enum_form_string_array = null, $enum_form_string = '-efg', $enum_header_string_array = null, $enum_header_string = '-efg', $enum_query_string_array = null, $enum_query_string = '-efg', $enum_query_integer = null, $enum_query_double = null) @@ -2007,8 +2163,9 @@ public function testEnumParameters($enum_form_string_array = null, $enum_form_st * @param int $enum_query_integer Query parameter enum test (double) (optional) * @param double $enum_query_double Query parameter enum test (double) (optional) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ public function testEnumParametersWithHttpInfo($enum_form_string_array = null, $enum_form_string = '-efg', $enum_header_string_array = null, $enum_header_string = '-efg', $enum_query_string_array = null, $enum_query_string = '-efg', $enum_query_integer = null, $enum_query_double = null) @@ -2020,13 +2177,17 @@ public function testEnumParametersWithHttpInfo($enum_form_string_array = null, $ $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -2068,6 +2229,7 @@ public function testEnumParametersWithHttpInfo($enum_form_string_array = null, $ * @param double $enum_query_double Query parameter enum test (double) (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function testEnumParametersAsync($enum_form_string_array = null, $enum_form_string = '-efg', $enum_header_string_array = null, $enum_header_string = '-efg', $enum_query_string_array = null, $enum_query_string = '-efg', $enum_query_integer = null, $enum_query_double = null) @@ -2095,6 +2257,7 @@ function ($response) { * @param double $enum_query_double Query parameter enum test (double) (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function testEnumParametersAsyncWithHttpInfo($enum_form_string_array = null, $enum_form_string = '-efg', $enum_header_string_array = null, $enum_header_string = '-efg', $enum_query_string_array = null, $enum_query_string = '-efg', $enum_query_integer = null, $enum_query_double = null) @@ -2109,17 +2272,23 @@ function ($response) use ($returnType) { return [null, $response->getStatusCode(), $response->getHeaders()]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -2138,6 +2307,7 @@ function ($exception) { * @param double $enum_query_double Query parameter enum test (double) (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function testEnumParametersRequest($enum_form_string_array = null, $enum_form_string = '-efg', $enum_header_string_array = null, $enum_header_string = '-efg', $enum_query_string_array = null, $enum_query_string = '-efg', $enum_query_integer = null, $enum_query_double = null) @@ -2152,8 +2322,8 @@ protected function testEnumParametersRequest($enum_form_string_array = null, $en // query params if (is_array($enum_query_string_array)) { - $enum_query_string_array = ObjectSerializer::serializeCollection($enum_query_string_array, 'csv', true); - } + $queryParams['enum_query_string_array'] = $enum_query_string_array; + } else if ($enum_query_string_array !== null) { $queryParams['enum_query_string_array'] = ObjectSerializer::toQueryValue($enum_query_string_array); } @@ -2208,9 +2378,16 @@ protected function testEnumParametersRequest($enum_form_string_array = null, $en if (isset($_tempBody)) { // $_tempBody is the method argument, if present $httpBody = $_tempBody; - // \stdClass has no __toString(), so we should encode it manually - if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($httpBody); + + if($headers['Content-Type'] === 'application/json') { + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass) { + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); + } + // array has no __toString(), so we should encode it manually + if(is_array($httpBody)) { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); + } } } elseif (count($formParams) > 0) { if ($multipart) { @@ -2225,7 +2402,7 @@ protected function testEnumParametersRequest($enum_form_string_array = null, $en $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -2261,8 +2438,9 @@ protected function testEnumParametersRequest($enum_form_string_array = null, $en * * @param object $param request body (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return void */ public function testInlineAdditionalProperties($param) @@ -2277,8 +2455,9 @@ public function testInlineAdditionalProperties($param) * * @param object $param request body (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ public function testInlineAdditionalPropertiesWithHttpInfo($param) @@ -2290,13 +2469,17 @@ public function testInlineAdditionalPropertiesWithHttpInfo($param) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -2331,6 +2514,7 @@ public function testInlineAdditionalPropertiesWithHttpInfo($param) * @param object $param request body (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function testInlineAdditionalPropertiesAsync($param) @@ -2351,6 +2535,7 @@ function ($response) { * @param object $param request body (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function testInlineAdditionalPropertiesAsyncWithHttpInfo($param) @@ -2365,17 +2550,23 @@ function ($response) use ($returnType) { return [null, $response->getStatusCode(), $response->getHeaders()]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -2387,6 +2578,7 @@ function ($exception) { * @param object $param request body (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function testInlineAdditionalPropertiesRequest($param) @@ -2428,9 +2620,16 @@ protected function testInlineAdditionalPropertiesRequest($param) if (isset($_tempBody)) { // $_tempBody is the method argument, if present $httpBody = $_tempBody; - // \stdClass has no __toString(), so we should encode it manually - if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($httpBody); + + if($headers['Content-Type'] === 'application/json') { + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass) { + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); + } + // array has no __toString(), so we should encode it manually + if(is_array($httpBody)) { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); + } } } elseif (count($formParams) > 0) { if ($multipart) { @@ -2445,7 +2644,7 @@ protected function testInlineAdditionalPropertiesRequest($param) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -2482,8 +2681,9 @@ protected function testInlineAdditionalPropertiesRequest($param) * @param string $param field1 (required) * @param string $param2 field2 (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return void */ public function testJsonFormData($param, $param2) @@ -2499,8 +2699,9 @@ public function testJsonFormData($param, $param2) * @param string $param field1 (required) * @param string $param2 field2 (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ public function testJsonFormDataWithHttpInfo($param, $param2) @@ -2512,13 +2713,17 @@ public function testJsonFormDataWithHttpInfo($param, $param2) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -2554,6 +2759,7 @@ public function testJsonFormDataWithHttpInfo($param, $param2) * @param string $param2 field2 (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function testJsonFormDataAsync($param, $param2) @@ -2575,6 +2781,7 @@ function ($response) { * @param string $param2 field2 (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function testJsonFormDataAsyncWithHttpInfo($param, $param2) @@ -2589,17 +2796,23 @@ function ($response) use ($returnType) { return [null, $response->getStatusCode(), $response->getHeaders()]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -2612,6 +2825,7 @@ function ($exception) { * @param string $param2 field2 (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function testJsonFormDataRequest($param, $param2) @@ -2664,9 +2878,16 @@ protected function testJsonFormDataRequest($param, $param2) if (isset($_tempBody)) { // $_tempBody is the method argument, if present $httpBody = $_tempBody; - // \stdClass has no __toString(), so we should encode it manually - if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($httpBody); + + if($headers['Content-Type'] === 'application/json') { + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass) { + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); + } + // array has no __toString(), so we should encode it manually + if(is_array($httpBody)) { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); + } } } elseif (count($formParams) > 0) { if ($multipart) { @@ -2681,7 +2902,7 @@ protected function testJsonFormDataRequest($param, $param2) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/FakeClassnameTags123Api.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/FakeClassnameTags123Api.php index 2b9ce933a6f..c5806b89ab7 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/FakeClassnameTags123Api.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/FakeClassnameTags123Api.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -30,7 +30,8 @@ use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\ResponseException; +use GuzzleHttp\Exception\TransferException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -70,9 +71,9 @@ class FakeClassnameTags123Api * @param HeaderSelector $selector */ public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); @@ -94,8 +95,9 @@ public function getConfig() * * @param \Swagger\Client\Model\Client $body client model (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return \Swagger\Client\Model\Client */ public function testClassname($body) @@ -111,8 +113,9 @@ public function testClassname($body) * * @param \Swagger\Client\Model\Client $body client model (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of \Swagger\Client\Model\Client, HTTP status code, HTTP response headers (array of strings) */ public function testClassnameWithHttpInfo($body) @@ -124,13 +127,17 @@ public function testClassnameWithHttpInfo($body) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -187,6 +194,7 @@ public function testClassnameWithHttpInfo($body) * @param \Swagger\Client\Model\Client $body client model (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function testClassnameAsync($body) @@ -207,6 +215,7 @@ function ($response) { * @param \Swagger\Client\Model\Client $body client model (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function testClassnameAsyncWithHttpInfo($body) @@ -235,17 +244,23 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -257,6 +272,7 @@ function ($exception) { * @param \Swagger\Client\Model\Client $body client model (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function testClassnameRequest($body) @@ -298,9 +314,16 @@ protected function testClassnameRequest($body) if (isset($_tempBody)) { // $_tempBody is the method argument, if present $httpBody = $_tempBody; - // \stdClass has no __toString(), so we should encode it manually - if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($httpBody); + + if($headers['Content-Type'] === 'application/json') { + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass) { + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); + } + // array has no __toString(), so we should encode it manually + if(is_array($httpBody)) { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); + } } } elseif (count($formParams) > 0) { if ($multipart) { @@ -315,7 +338,7 @@ protected function testClassnameRequest($body) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php index 85df4c18fa1..6429759b566 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -12,12 +12,12 @@ /** * Swagger Petstore * - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -30,7 +30,8 @@ use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\ResponseException; +use GuzzleHttp\Exception\TransferException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -70,9 +71,9 @@ class PetApi * @param HeaderSelector $selector */ public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); @@ -94,8 +95,9 @@ public function getConfig() * * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return void */ public function addPet($body) @@ -110,8 +112,9 @@ public function addPet($body) * * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ public function addPetWithHttpInfo($body) @@ -123,13 +126,17 @@ public function addPetWithHttpInfo($body) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -164,6 +171,7 @@ public function addPetWithHttpInfo($body) * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function addPetAsync($body) @@ -184,6 +192,7 @@ function ($response) { * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function addPetAsyncWithHttpInfo($body) @@ -198,17 +207,23 @@ function ($response) use ($returnType) { return [null, $response->getStatusCode(), $response->getHeaders()]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -220,6 +235,7 @@ function ($exception) { * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function addPetRequest($body) @@ -265,11 +281,11 @@ protected function addPetRequest($body) if($headers['Content-Type'] === 'application/json') { // \stdClass has no __toString(), so we should encode it manually if ($httpBody instanceof \stdClass) { - $httpBody = \GuzzleHttp\json_encode($httpBody); + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); } // array has no __toString(), so we should encode it manually if(is_array($httpBody)) { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); } } } elseif (count($formParams) > 0) { @@ -285,7 +301,7 @@ protected function addPetRequest($body) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -326,8 +342,9 @@ protected function addPetRequest($body) * @param int $pet_id Pet id to delete (required) * @param string $api_key api_key (optional) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return void */ public function deletePet($pet_id, $api_key = null) @@ -343,8 +360,9 @@ public function deletePet($pet_id, $api_key = null) * @param int $pet_id Pet id to delete (required) * @param string $api_key (optional) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ public function deletePetWithHttpInfo($pet_id, $api_key = null) @@ -356,13 +374,17 @@ public function deletePetWithHttpInfo($pet_id, $api_key = null) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -398,6 +420,7 @@ public function deletePetWithHttpInfo($pet_id, $api_key = null) * @param string $api_key (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function deletePetAsync($pet_id, $api_key = null) @@ -419,6 +442,7 @@ function ($response) { * @param string $api_key (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function deletePetAsyncWithHttpInfo($pet_id, $api_key = null) @@ -433,17 +457,23 @@ function ($response) use ($returnType) { return [null, $response->getStatusCode(), $response->getHeaders()]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -456,6 +486,7 @@ function ($exception) { * @param string $api_key (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function deletePetRequest($pet_id, $api_key = null) @@ -510,11 +541,11 @@ protected function deletePetRequest($pet_id, $api_key = null) if($headers['Content-Type'] === 'application/json') { // \stdClass has no __toString(), so we should encode it manually if ($httpBody instanceof \stdClass) { - $httpBody = \GuzzleHttp\json_encode($httpBody); + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); } // array has no __toString(), so we should encode it manually if(is_array($httpBody)) { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); } } } elseif (count($formParams) > 0) { @@ -530,7 +561,7 @@ protected function deletePetRequest($pet_id, $api_key = null) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -570,8 +601,9 @@ protected function deletePetRequest($pet_id, $api_key = null) * * @param string[] $status Status values that need to be considered for filter (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return \Swagger\Client\Model\Pet[] */ public function findPetsByStatus($status) @@ -587,8 +619,9 @@ public function findPetsByStatus($status) * * @param string[] $status Status values that need to be considered for filter (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of \Swagger\Client\Model\Pet[], HTTP status code, HTTP response headers (array of strings) */ public function findPetsByStatusWithHttpInfo($status) @@ -600,13 +633,17 @@ public function findPetsByStatusWithHttpInfo($status) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -663,6 +700,7 @@ public function findPetsByStatusWithHttpInfo($status) * @param string[] $status Status values that need to be considered for filter (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function findPetsByStatusAsync($status) @@ -683,6 +721,7 @@ function ($response) { * @param string[] $status Status values that need to be considered for filter (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function findPetsByStatusAsyncWithHttpInfo($status) @@ -711,17 +750,23 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -733,6 +778,7 @@ function ($exception) { * @param string[] $status Status values that need to be considered for filter (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function findPetsByStatusRequest($status) @@ -782,11 +828,11 @@ protected function findPetsByStatusRequest($status) if($headers['Content-Type'] === 'application/json') { // \stdClass has no __toString(), so we should encode it manually if ($httpBody instanceof \stdClass) { - $httpBody = \GuzzleHttp\json_encode($httpBody); + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); } // array has no __toString(), so we should encode it manually if(is_array($httpBody)) { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); } } } elseif (count($formParams) > 0) { @@ -802,7 +848,7 @@ protected function findPetsByStatusRequest($status) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -842,8 +888,9 @@ protected function findPetsByStatusRequest($status) * * @param string[] $tags Tags to filter by (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return \Swagger\Client\Model\Pet[] */ public function findPetsByTags($tags) @@ -859,8 +906,9 @@ public function findPetsByTags($tags) * * @param string[] $tags Tags to filter by (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of \Swagger\Client\Model\Pet[], HTTP status code, HTTP response headers (array of strings) */ public function findPetsByTagsWithHttpInfo($tags) @@ -872,13 +920,17 @@ public function findPetsByTagsWithHttpInfo($tags) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -935,6 +987,7 @@ public function findPetsByTagsWithHttpInfo($tags) * @param string[] $tags Tags to filter by (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function findPetsByTagsAsync($tags) @@ -955,6 +1008,7 @@ function ($response) { * @param string[] $tags Tags to filter by (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function findPetsByTagsAsyncWithHttpInfo($tags) @@ -983,17 +1037,23 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -1005,6 +1065,7 @@ function ($exception) { * @param string[] $tags Tags to filter by (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function findPetsByTagsRequest($tags) @@ -1054,11 +1115,11 @@ protected function findPetsByTagsRequest($tags) if($headers['Content-Type'] === 'application/json') { // \stdClass has no __toString(), so we should encode it manually if ($httpBody instanceof \stdClass) { - $httpBody = \GuzzleHttp\json_encode($httpBody); + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); } // array has no __toString(), so we should encode it manually if(is_array($httpBody)) { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); } } } elseif (count($formParams) > 0) { @@ -1074,7 +1135,7 @@ protected function findPetsByTagsRequest($tags) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -1114,8 +1175,9 @@ protected function findPetsByTagsRequest($tags) * * @param int $pet_id ID of pet to return (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return \Swagger\Client\Model\Pet */ public function getPetById($pet_id) @@ -1131,8 +1193,9 @@ public function getPetById($pet_id) * * @param int $pet_id ID of pet to return (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of \Swagger\Client\Model\Pet, HTTP status code, HTTP response headers (array of strings) */ public function getPetByIdWithHttpInfo($pet_id) @@ -1144,13 +1207,17 @@ public function getPetByIdWithHttpInfo($pet_id) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -1207,6 +1274,7 @@ public function getPetByIdWithHttpInfo($pet_id) * @param int $pet_id ID of pet to return (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getPetByIdAsync($pet_id) @@ -1227,6 +1295,7 @@ function ($response) { * @param int $pet_id ID of pet to return (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getPetByIdAsyncWithHttpInfo($pet_id) @@ -1255,17 +1324,23 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -1277,6 +1352,7 @@ function ($exception) { * @param int $pet_id ID of pet to return (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function getPetByIdRequest($pet_id) @@ -1327,11 +1403,11 @@ protected function getPetByIdRequest($pet_id) if($headers['Content-Type'] === 'application/json') { // \stdClass has no __toString(), so we should encode it manually if ($httpBody instanceof \stdClass) { - $httpBody = \GuzzleHttp\json_encode($httpBody); + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); } // array has no __toString(), so we should encode it manually if(is_array($httpBody)) { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); } } } elseif (count($formParams) > 0) { @@ -1347,7 +1423,7 @@ protected function getPetByIdRequest($pet_id) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -1388,8 +1464,9 @@ protected function getPetByIdRequest($pet_id) * * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return void */ public function updatePet($body) @@ -1404,8 +1481,9 @@ public function updatePet($body) * * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ public function updatePetWithHttpInfo($body) @@ -1417,13 +1495,17 @@ public function updatePetWithHttpInfo($body) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -1458,6 +1540,7 @@ public function updatePetWithHttpInfo($body) * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function updatePetAsync($body) @@ -1478,6 +1561,7 @@ function ($response) { * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function updatePetAsyncWithHttpInfo($body) @@ -1492,17 +1576,23 @@ function ($response) use ($returnType) { return [null, $response->getStatusCode(), $response->getHeaders()]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -1514,6 +1604,7 @@ function ($exception) { * @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function updatePetRequest($body) @@ -1559,11 +1650,11 @@ protected function updatePetRequest($body) if($headers['Content-Type'] === 'application/json') { // \stdClass has no __toString(), so we should encode it manually if ($httpBody instanceof \stdClass) { - $httpBody = \GuzzleHttp\json_encode($httpBody); + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); } // array has no __toString(), so we should encode it manually if(is_array($httpBody)) { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); } } } elseif (count($formParams) > 0) { @@ -1579,7 +1670,7 @@ protected function updatePetRequest($body) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -1621,8 +1712,9 @@ protected function updatePetRequest($body) * @param string $name Updated name of the pet (optional) * @param string $status Updated status of the pet (optional) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return void */ public function updatePetWithForm($pet_id, $name = null, $status = null) @@ -1639,8 +1731,9 @@ public function updatePetWithForm($pet_id, $name = null, $status = null) * @param string $name Updated name of the pet (optional) * @param string $status Updated status of the pet (optional) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ public function updatePetWithFormWithHttpInfo($pet_id, $name = null, $status = null) @@ -1652,13 +1745,17 @@ public function updatePetWithFormWithHttpInfo($pet_id, $name = null, $status = n $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -1695,6 +1792,7 @@ public function updatePetWithFormWithHttpInfo($pet_id, $name = null, $status = n * @param string $status Updated status of the pet (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function updatePetWithFormAsync($pet_id, $name = null, $status = null) @@ -1717,6 +1815,7 @@ function ($response) { * @param string $status Updated status of the pet (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function updatePetWithFormAsyncWithHttpInfo($pet_id, $name = null, $status = null) @@ -1731,17 +1830,23 @@ function ($response) use ($returnType) { return [null, $response->getStatusCode(), $response->getHeaders()]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -1755,6 +1860,7 @@ function ($exception) { * @param string $status Updated status of the pet (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function updatePetWithFormRequest($pet_id, $name = null, $status = null) @@ -1813,11 +1919,11 @@ protected function updatePetWithFormRequest($pet_id, $name = null, $status = nul if($headers['Content-Type'] === 'application/json') { // \stdClass has no __toString(), so we should encode it manually if ($httpBody instanceof \stdClass) { - $httpBody = \GuzzleHttp\json_encode($httpBody); + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); } // array has no __toString(), so we should encode it manually if(is_array($httpBody)) { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); } } } elseif (count($formParams) > 0) { @@ -1833,7 +1939,7 @@ protected function updatePetWithFormRequest($pet_id, $name = null, $status = nul $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -1875,8 +1981,9 @@ protected function updatePetWithFormRequest($pet_id, $name = null, $status = nul * @param string $additional_metadata Additional data to pass to server (optional) * @param \SplFileObject $file file to upload (optional) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return \Swagger\Client\Model\ApiResponse */ public function uploadFile($pet_id, $additional_metadata = null, $file = null) @@ -1894,8 +2001,9 @@ public function uploadFile($pet_id, $additional_metadata = null, $file = null) * @param string $additional_metadata Additional data to pass to server (optional) * @param \SplFileObject $file file to upload (optional) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of \Swagger\Client\Model\ApiResponse, HTTP status code, HTTP response headers (array of strings) */ public function uploadFileWithHttpInfo($pet_id, $additional_metadata = null, $file = null) @@ -1907,13 +2015,17 @@ public function uploadFileWithHttpInfo($pet_id, $additional_metadata = null, $fi $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -1972,6 +2084,7 @@ public function uploadFileWithHttpInfo($pet_id, $additional_metadata = null, $fi * @param \SplFileObject $file file to upload (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function uploadFileAsync($pet_id, $additional_metadata = null, $file = null) @@ -1994,6 +2107,7 @@ function ($response) { * @param \SplFileObject $file file to upload (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function uploadFileAsyncWithHttpInfo($pet_id, $additional_metadata = null, $file = null) @@ -2022,17 +2136,23 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -2046,6 +2166,7 @@ function ($exception) { * @param \SplFileObject $file file to upload (optional) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function uploadFileRequest($pet_id, $additional_metadata = null, $file = null) @@ -2081,7 +2202,7 @@ protected function uploadFileRequest($pet_id, $additional_metadata = null, $file // form params if ($file !== null) { $multipart = true; - $formParams['file'] = \GuzzleHttp\Psr7\try_fopen(ObjectSerializer::toFormValue($file), 'rb'); + $formParams['file'] = \GuzzleHttp\Psr7\Utils::tryFopen(ObjectSerializer::toFormValue($file), 'rb'); } // body params $_tempBody = null; @@ -2105,11 +2226,11 @@ protected function uploadFileRequest($pet_id, $additional_metadata = null, $file if($headers['Content-Type'] === 'application/json') { // \stdClass has no __toString(), so we should encode it manually if ($httpBody instanceof \stdClass) { - $httpBody = \GuzzleHttp\json_encode($httpBody); + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); } // array has no __toString(), so we should encode it manually if(is_array($httpBody)) { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); } } } elseif (count($formParams) > 0) { @@ -2125,7 +2246,7 @@ protected function uploadFileRequest($pet_id, $additional_metadata = null, $file $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php index a65dd45a52c..91b30a9ec43 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php @@ -12,12 +12,12 @@ /** * Swagger Petstore * - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -30,7 +30,8 @@ use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\ResponseException; +use GuzzleHttp\Exception\TransferException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -70,9 +71,9 @@ class StoreApi * @param HeaderSelector $selector */ public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); @@ -94,8 +95,9 @@ public function getConfig() * * @param string $order_id ID of the order that needs to be deleted (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return void */ public function deleteOrder($order_id) @@ -110,8 +112,9 @@ public function deleteOrder($order_id) * * @param string $order_id ID of the order that needs to be deleted (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ public function deleteOrderWithHttpInfo($order_id) @@ -123,13 +126,17 @@ public function deleteOrderWithHttpInfo($order_id) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -164,6 +171,7 @@ public function deleteOrderWithHttpInfo($order_id) * @param string $order_id ID of the order that needs to be deleted (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function deleteOrderAsync($order_id) @@ -184,6 +192,7 @@ function ($response) { * @param string $order_id ID of the order that needs to be deleted (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function deleteOrderAsyncWithHttpInfo($order_id) @@ -198,17 +207,23 @@ function ($response) use ($returnType) { return [null, $response->getStatusCode(), $response->getHeaders()]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -220,6 +235,7 @@ function ($exception) { * @param string $order_id ID of the order that needs to be deleted (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function deleteOrderRequest($order_id) @@ -231,7 +247,7 @@ protected function deleteOrderRequest($order_id) ); } - $resourcePath = '/store/order/{orderId}'; + $resourcePath = '/store/order/{order_id}'; $formParams = []; $queryParams = []; $headerParams = []; @@ -242,7 +258,7 @@ protected function deleteOrderRequest($order_id) // path params if ($order_id !== null) { $resourcePath = str_replace( - '{' . 'orderId' . '}', + '{' . 'order_id' . '}', ObjectSerializer::toPathValue($order_id), $resourcePath ); @@ -270,11 +286,11 @@ protected function deleteOrderRequest($order_id) if($headers['Content-Type'] === 'application/json') { // \stdClass has no __toString(), so we should encode it manually if ($httpBody instanceof \stdClass) { - $httpBody = \GuzzleHttp\json_encode($httpBody); + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); } // array has no __toString(), so we should encode it manually if(is_array($httpBody)) { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); } } } elseif (count($formParams) > 0) { @@ -290,7 +306,7 @@ protected function deleteOrderRequest($order_id) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -325,8 +341,9 @@ protected function deleteOrderRequest($order_id) * Returns pet inventories by status * * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return map[string,int] */ public function getInventory() @@ -341,8 +358,9 @@ public function getInventory() * Returns pet inventories by status * * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of map[string,int], HTTP status code, HTTP response headers (array of strings) */ public function getInventoryWithHttpInfo() @@ -354,13 +372,17 @@ public function getInventoryWithHttpInfo() $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -416,6 +438,7 @@ public function getInventoryWithHttpInfo() * * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getInventoryAsync() @@ -435,6 +458,7 @@ function ($response) { * * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getInventoryAsyncWithHttpInfo() @@ -463,17 +487,23 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -484,6 +514,7 @@ function ($exception) { * * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function getInventoryRequest() @@ -520,11 +551,11 @@ protected function getInventoryRequest() if($headers['Content-Type'] === 'application/json') { // \stdClass has no __toString(), so we should encode it manually if ($httpBody instanceof \stdClass) { - $httpBody = \GuzzleHttp\json_encode($httpBody); + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); } // array has no __toString(), so we should encode it manually if(is_array($httpBody)) { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); } } } elseif (count($formParams) > 0) { @@ -540,7 +571,7 @@ protected function getInventoryRequest() $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -581,8 +612,9 @@ protected function getInventoryRequest() * * @param int $order_id ID of pet that needs to be fetched (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return \Swagger\Client\Model\Order */ public function getOrderById($order_id) @@ -598,8 +630,9 @@ public function getOrderById($order_id) * * @param int $order_id ID of pet that needs to be fetched (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of \Swagger\Client\Model\Order, HTTP status code, HTTP response headers (array of strings) */ public function getOrderByIdWithHttpInfo($order_id) @@ -611,13 +644,17 @@ public function getOrderByIdWithHttpInfo($order_id) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -674,6 +711,7 @@ public function getOrderByIdWithHttpInfo($order_id) * @param int $order_id ID of pet that needs to be fetched (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getOrderByIdAsync($order_id) @@ -694,6 +732,7 @@ function ($response) { * @param int $order_id ID of pet that needs to be fetched (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getOrderByIdAsyncWithHttpInfo($order_id) @@ -722,17 +761,23 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -744,6 +789,7 @@ function ($exception) { * @param int $order_id ID of pet that needs to be fetched (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function getOrderByIdRequest($order_id) @@ -762,7 +808,7 @@ protected function getOrderByIdRequest($order_id) } - $resourcePath = '/store/order/{orderId}'; + $resourcePath = '/store/order/{order_id}'; $formParams = []; $queryParams = []; $headerParams = []; @@ -773,7 +819,7 @@ protected function getOrderByIdRequest($order_id) // path params if ($order_id !== null) { $resourcePath = str_replace( - '{' . 'orderId' . '}', + '{' . 'order_id' . '}', ObjectSerializer::toPathValue($order_id), $resourcePath ); @@ -801,11 +847,11 @@ protected function getOrderByIdRequest($order_id) if($headers['Content-Type'] === 'application/json') { // \stdClass has no __toString(), so we should encode it manually if ($httpBody instanceof \stdClass) { - $httpBody = \GuzzleHttp\json_encode($httpBody); + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); } // array has no __toString(), so we should encode it manually if(is_array($httpBody)) { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); } } } elseif (count($formParams) > 0) { @@ -821,7 +867,7 @@ protected function getOrderByIdRequest($order_id) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -857,8 +903,9 @@ protected function getOrderByIdRequest($order_id) * * @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return \Swagger\Client\Model\Order */ public function placeOrder($body) @@ -874,8 +921,9 @@ public function placeOrder($body) * * @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of \Swagger\Client\Model\Order, HTTP status code, HTTP response headers (array of strings) */ public function placeOrderWithHttpInfo($body) @@ -887,13 +935,17 @@ public function placeOrderWithHttpInfo($body) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -950,6 +1002,7 @@ public function placeOrderWithHttpInfo($body) * @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function placeOrderAsync($body) @@ -970,6 +1023,7 @@ function ($response) { * @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function placeOrderAsyncWithHttpInfo($body) @@ -998,17 +1052,23 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -1020,6 +1080,7 @@ function ($exception) { * @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function placeOrderRequest($body) @@ -1065,11 +1126,11 @@ protected function placeOrderRequest($body) if($headers['Content-Type'] === 'application/json') { // \stdClass has no __toString(), so we should encode it manually if ($httpBody instanceof \stdClass) { - $httpBody = \GuzzleHttp\json_encode($httpBody); + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); } // array has no __toString(), so we should encode it manually if(is_array($httpBody)) { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); } } } elseif (count($formParams) > 0) { @@ -1085,7 +1146,7 @@ protected function placeOrderRequest($body) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php index edf55946bae..6d8ce3a1bd7 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php @@ -12,12 +12,12 @@ /** * Swagger Petstore * - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -30,7 +30,8 @@ use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; -use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Exception\ResponseException; +use GuzzleHttp\Exception\TransferException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; @@ -70,9 +71,9 @@ class UserApi * @param HeaderSelector $selector */ public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); @@ -94,8 +95,9 @@ public function getConfig() * * @param \Swagger\Client\Model\User $body Created user object (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return void */ public function createUser($body) @@ -110,8 +112,9 @@ public function createUser($body) * * @param \Swagger\Client\Model\User $body Created user object (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ public function createUserWithHttpInfo($body) @@ -123,13 +126,17 @@ public function createUserWithHttpInfo($body) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -164,6 +171,7 @@ public function createUserWithHttpInfo($body) * @param \Swagger\Client\Model\User $body Created user object (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function createUserAsync($body) @@ -184,6 +192,7 @@ function ($response) { * @param \Swagger\Client\Model\User $body Created user object (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function createUserAsyncWithHttpInfo($body) @@ -198,17 +207,23 @@ function ($response) use ($returnType) { return [null, $response->getStatusCode(), $response->getHeaders()]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -220,6 +235,7 @@ function ($exception) { * @param \Swagger\Client\Model\User $body Created user object (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function createUserRequest($body) @@ -265,11 +281,11 @@ protected function createUserRequest($body) if($headers['Content-Type'] === 'application/json') { // \stdClass has no __toString(), so we should encode it manually if ($httpBody instanceof \stdClass) { - $httpBody = \GuzzleHttp\json_encode($httpBody); + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); } // array has no __toString(), so we should encode it manually if(is_array($httpBody)) { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); } } } elseif (count($formParams) > 0) { @@ -285,7 +301,7 @@ protected function createUserRequest($body) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -321,8 +337,9 @@ protected function createUserRequest($body) * * @param \Swagger\Client\Model\User[] $body List of user object (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return void */ public function createUsersWithArrayInput($body) @@ -337,8 +354,9 @@ public function createUsersWithArrayInput($body) * * @param \Swagger\Client\Model\User[] $body List of user object (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ public function createUsersWithArrayInputWithHttpInfo($body) @@ -350,13 +368,17 @@ public function createUsersWithArrayInputWithHttpInfo($body) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -391,6 +413,7 @@ public function createUsersWithArrayInputWithHttpInfo($body) * @param \Swagger\Client\Model\User[] $body List of user object (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function createUsersWithArrayInputAsync($body) @@ -411,6 +434,7 @@ function ($response) { * @param \Swagger\Client\Model\User[] $body List of user object (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function createUsersWithArrayInputAsyncWithHttpInfo($body) @@ -425,17 +449,23 @@ function ($response) use ($returnType) { return [null, $response->getStatusCode(), $response->getHeaders()]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -447,6 +477,7 @@ function ($exception) { * @param \Swagger\Client\Model\User[] $body List of user object (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function createUsersWithArrayInputRequest($body) @@ -492,11 +523,11 @@ protected function createUsersWithArrayInputRequest($body) if($headers['Content-Type'] === 'application/json') { // \stdClass has no __toString(), so we should encode it manually if ($httpBody instanceof \stdClass) { - $httpBody = \GuzzleHttp\json_encode($httpBody); + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); } // array has no __toString(), so we should encode it manually if(is_array($httpBody)) { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); } } } elseif (count($formParams) > 0) { @@ -512,7 +543,7 @@ protected function createUsersWithArrayInputRequest($body) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -548,8 +579,9 @@ protected function createUsersWithArrayInputRequest($body) * * @param \Swagger\Client\Model\User[] $body List of user object (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return void */ public function createUsersWithListInput($body) @@ -564,8 +596,9 @@ public function createUsersWithListInput($body) * * @param \Swagger\Client\Model\User[] $body List of user object (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ public function createUsersWithListInputWithHttpInfo($body) @@ -577,13 +610,17 @@ public function createUsersWithListInputWithHttpInfo($body) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -618,6 +655,7 @@ public function createUsersWithListInputWithHttpInfo($body) * @param \Swagger\Client\Model\User[] $body List of user object (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function createUsersWithListInputAsync($body) @@ -638,6 +676,7 @@ function ($response) { * @param \Swagger\Client\Model\User[] $body List of user object (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function createUsersWithListInputAsyncWithHttpInfo($body) @@ -652,17 +691,23 @@ function ($response) use ($returnType) { return [null, $response->getStatusCode(), $response->getHeaders()]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -674,6 +719,7 @@ function ($exception) { * @param \Swagger\Client\Model\User[] $body List of user object (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function createUsersWithListInputRequest($body) @@ -719,11 +765,11 @@ protected function createUsersWithListInputRequest($body) if($headers['Content-Type'] === 'application/json') { // \stdClass has no __toString(), so we should encode it manually if ($httpBody instanceof \stdClass) { - $httpBody = \GuzzleHttp\json_encode($httpBody); + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); } // array has no __toString(), so we should encode it manually if(is_array($httpBody)) { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); } } } elseif (count($formParams) > 0) { @@ -739,7 +785,7 @@ protected function createUsersWithListInputRequest($body) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -775,8 +821,9 @@ protected function createUsersWithListInputRequest($body) * * @param string $username The name that needs to be deleted (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return void */ public function deleteUser($username) @@ -791,8 +838,9 @@ public function deleteUser($username) * * @param string $username The name that needs to be deleted (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ public function deleteUserWithHttpInfo($username) @@ -804,13 +852,17 @@ public function deleteUserWithHttpInfo($username) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -845,6 +897,7 @@ public function deleteUserWithHttpInfo($username) * @param string $username The name that needs to be deleted (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function deleteUserAsync($username) @@ -865,6 +918,7 @@ function ($response) { * @param string $username The name that needs to be deleted (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function deleteUserAsyncWithHttpInfo($username) @@ -879,17 +933,23 @@ function ($response) use ($returnType) { return [null, $response->getStatusCode(), $response->getHeaders()]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -901,6 +961,7 @@ function ($exception) { * @param string $username The name that needs to be deleted (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function deleteUserRequest($username) @@ -951,11 +1012,11 @@ protected function deleteUserRequest($username) if($headers['Content-Type'] === 'application/json') { // \stdClass has no __toString(), so we should encode it manually if ($httpBody instanceof \stdClass) { - $httpBody = \GuzzleHttp\json_encode($httpBody); + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); } // array has no __toString(), so we should encode it manually if(is_array($httpBody)) { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); } } } elseif (count($formParams) > 0) { @@ -971,7 +1032,7 @@ protected function deleteUserRequest($username) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -1007,8 +1068,9 @@ protected function deleteUserRequest($username) * * @param string $username The name that needs to be fetched. Use user1 for testing. (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return \Swagger\Client\Model\User */ public function getUserByName($username) @@ -1024,8 +1086,9 @@ public function getUserByName($username) * * @param string $username The name that needs to be fetched. Use user1 for testing. (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of \Swagger\Client\Model\User, HTTP status code, HTTP response headers (array of strings) */ public function getUserByNameWithHttpInfo($username) @@ -1037,13 +1100,17 @@ public function getUserByNameWithHttpInfo($username) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -1100,6 +1167,7 @@ public function getUserByNameWithHttpInfo($username) * @param string $username The name that needs to be fetched. Use user1 for testing. (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getUserByNameAsync($username) @@ -1120,6 +1188,7 @@ function ($response) { * @param string $username The name that needs to be fetched. Use user1 for testing. (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getUserByNameAsyncWithHttpInfo($username) @@ -1148,17 +1217,23 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -1170,6 +1245,7 @@ function ($exception) { * @param string $username The name that needs to be fetched. Use user1 for testing. (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function getUserByNameRequest($username) @@ -1220,11 +1296,11 @@ protected function getUserByNameRequest($username) if($headers['Content-Type'] === 'application/json') { // \stdClass has no __toString(), so we should encode it manually if ($httpBody instanceof \stdClass) { - $httpBody = \GuzzleHttp\json_encode($httpBody); + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); } // array has no __toString(), so we should encode it manually if(is_array($httpBody)) { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); } } } elseif (count($formParams) > 0) { @@ -1240,7 +1316,7 @@ protected function getUserByNameRequest($username) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -1277,8 +1353,9 @@ protected function getUserByNameRequest($username) * @param string $username The user name for login (required) * @param string $password The password for login in clear text (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return string */ public function loginUser($username, $password) @@ -1295,8 +1372,9 @@ public function loginUser($username, $password) * @param string $username The user name for login (required) * @param string $password The password for login in clear text (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of string, HTTP status code, HTTP response headers (array of strings) */ public function loginUserWithHttpInfo($username, $password) @@ -1308,13 +1386,17 @@ public function loginUserWithHttpInfo($username, $password) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -1372,6 +1454,7 @@ public function loginUserWithHttpInfo($username, $password) * @param string $password The password for login in clear text (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function loginUserAsync($username, $password) @@ -1393,6 +1476,7 @@ function ($response) { * @param string $password The password for login in clear text (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function loginUserAsyncWithHttpInfo($username, $password) @@ -1421,17 +1505,23 @@ function ($response) use ($returnType) { ]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -1444,6 +1534,7 @@ function ($exception) { * @param string $password The password for login in clear text (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function loginUserRequest($username, $password) @@ -1500,11 +1591,11 @@ protected function loginUserRequest($username, $password) if($headers['Content-Type'] === 'application/json') { // \stdClass has no __toString(), so we should encode it manually if ($httpBody instanceof \stdClass) { - $httpBody = \GuzzleHttp\json_encode($httpBody); + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); } // array has no __toString(), so we should encode it manually if(is_array($httpBody)) { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); } } } elseif (count($formParams) > 0) { @@ -1520,7 +1611,7 @@ protected function loginUserRequest($username, $password) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -1555,8 +1646,9 @@ protected function loginUserRequest($username, $password) * Logs out current logged in user session * * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return void */ public function logoutUser() @@ -1570,8 +1662,9 @@ public function logoutUser() * Logs out current logged in user session * * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ public function logoutUserWithHttpInfo() @@ -1583,13 +1676,17 @@ public function logoutUserWithHttpInfo() $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -1623,6 +1720,7 @@ public function logoutUserWithHttpInfo() * * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function logoutUserAsync() @@ -1642,6 +1740,7 @@ function ($response) { * * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function logoutUserAsyncWithHttpInfo() @@ -1656,17 +1755,23 @@ function ($response) use ($returnType) { return [null, $response->getStatusCode(), $response->getHeaders()]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -1677,6 +1782,7 @@ function ($exception) { * * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function logoutUserRequest() @@ -1713,11 +1819,11 @@ protected function logoutUserRequest() if($headers['Content-Type'] === 'application/json') { // \stdClass has no __toString(), so we should encode it manually if ($httpBody instanceof \stdClass) { - $httpBody = \GuzzleHttp\json_encode($httpBody); + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); } // array has no __toString(), so we should encode it manually if(is_array($httpBody)) { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); } } } elseif (count($formParams) > 0) { @@ -1733,7 +1839,7 @@ protected function logoutUserRequest() $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) @@ -1770,8 +1876,9 @@ protected function logoutUserRequest() * @param string $username name that need to be deleted (required) * @param \Swagger\Client\Model\User $body Updated user object (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return void */ public function updateUser($username, $body) @@ -1787,8 +1894,9 @@ public function updateUser($username, $body) * @param string $username name that need to be deleted (required) * @param \Swagger\Client\Model\User $body Updated user object (required) * - * @throws \Swagger\Client\ApiException on non-2xx response + * @throws \Swagger\Client\ApiException on non-2xx response or a failure without a response * @throws \InvalidArgumentException + * @throws \JsonException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ public function updateUserWithHttpInfo($username, $body) @@ -1800,13 +1908,17 @@ public function updateUserWithHttpInfo($username, $body) $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); - } catch (RequestException $e) { + } catch (ResponseException $e) { + $response = $e->getResponse(); throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + $response->getHeaders(), + $response->getBody()->getContents() ); + } catch (TransferException $e) { + // e.g. connection errors: there is no response + throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode()); } $statusCode = $response->getStatusCode(); @@ -1842,6 +1954,7 @@ public function updateUserWithHttpInfo($username, $body) * @param \Swagger\Client\Model\User $body Updated user object (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function updateUserAsync($username, $body) @@ -1863,6 +1976,7 @@ function ($response) { * @param \Swagger\Client\Model\User $body Updated user object (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Promise\PromiseInterface */ public function updateUserAsyncWithHttpInfo($username, $body) @@ -1877,17 +1991,23 @@ function ($response) use ($returnType) { return [null, $response->getStatusCode(), $response->getHeaders()]; }, function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', + if ($exception instanceof ResponseException) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - $response->getBody() + $response->getHeaders(), + $response->getBody() + ); + } + throw new ApiException( + sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()), + $exception->getCode() ); } ); @@ -1900,6 +2020,7 @@ function ($exception) { * @param \Swagger\Client\Model\User $body Updated user object (required) * * @throws \InvalidArgumentException + * @throws \JsonException * @return \GuzzleHttp\Psr7\Request */ protected function updateUserRequest($username, $body) @@ -1959,11 +2080,11 @@ protected function updateUserRequest($username, $body) if($headers['Content-Type'] === 'application/json') { // \stdClass has no __toString(), so we should encode it manually if ($httpBody instanceof \stdClass) { - $httpBody = \GuzzleHttp\json_encode($httpBody); + $httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR); } // array has no __toString(), so we should encode it manually if(is_array($httpBody)) { - $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR); } } } elseif (count($formParams) > 0) { @@ -1979,7 +2100,7 @@ protected function updateUserRequest($username, $body) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($formParams); + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); } else { // for HTTP post (form) diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ApiException.php b/samples/client/petstore/php/SwaggerClient-php/lib/ApiException.php index 38d93510c96..0815abef667 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ApiException.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ApiException.php @@ -12,12 +12,12 @@ /** * Swagger Petstore * - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Configuration.php b/samples/client/petstore/php/SwaggerClient-php/lib/Configuration.php index fb610939c5b..420e702d114 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Configuration.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Configuration.php @@ -12,12 +12,12 @@ /** * Swagger Petstore * - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -81,7 +81,7 @@ class Configuration * * @var string */ - protected $host = 'http://petstore.swagger.io/v2'; + protected $host = 'http://petstore.swagger.io:80/v2'; /** * User agent of the HTTP request, set to "PHP-Swagger" by default diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/HeaderSelector.php b/samples/client/petstore/php/SwaggerClient-php/lib/HeaderSelector.php index 00235d1a77a..3d5b235048e 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/HeaderSelector.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/HeaderSelector.php @@ -12,12 +12,12 @@ /** * Swagger Petstore * - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/AdditionalPropertiesClass.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/AdditionalPropertiesClass.php index 74369007f91..4b28d446a78 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/AdditionalPropertiesClass.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/AdditionalPropertiesClass.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -264,6 +264,7 @@ public function setMapOfMapProperty($map_of_map_property) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -276,6 +277,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -289,6 +291,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -305,6 +308,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Animal.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Animal.php index 706f7d82600..156732f0525 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Animal.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Animal.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -271,6 +271,7 @@ public function setColor($color) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -283,6 +284,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -296,6 +298,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -312,6 +315,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/AnimalFarm.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/AnimalFarm.php index c0bffb19198..2bcc1788c19 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/AnimalFarm.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/AnimalFarm.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -209,6 +209,7 @@ public function valid() * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -221,6 +222,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -234,6 +236,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -250,6 +253,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ApiResponse.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ApiResponse.php index e4439f756b1..c26a1598aa7 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ApiResponse.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ApiResponse.php @@ -13,12 +13,12 @@ /** * Swagger Petstore * - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -36,7 +36,6 @@ * ApiResponse Class Doc Comment * * @category Class - * @description Describes the result of uploading an image resource * @package Swagger\Client * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen @@ -295,6 +294,7 @@ public function setMessage($message) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -307,6 +307,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -320,6 +321,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -336,6 +338,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ArrayOfArrayOfNumberOnly.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ArrayOfArrayOfNumberOnly.php index a9d2f531649..72009f51b6d 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ArrayOfArrayOfNumberOnly.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ArrayOfArrayOfNumberOnly.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -234,6 +234,7 @@ public function setArrayArrayNumber($array_array_number) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -246,6 +247,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -259,6 +261,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -275,6 +278,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ArrayOfNumberOnly.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ArrayOfNumberOnly.php index c5b73d07dfc..0d88fdf0903 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ArrayOfNumberOnly.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ArrayOfNumberOnly.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -234,6 +234,7 @@ public function setArrayNumber($array_number) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -246,6 +247,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -259,6 +261,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -275,6 +278,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ArrayTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ArrayTest.php index 9a7efa27283..74ee96b7a78 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ArrayTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ArrayTest.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -294,6 +294,7 @@ public function setArrayArrayOfModel($array_array_of_model) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -306,6 +307,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -319,6 +321,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -335,6 +338,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Boolean.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Boolean.php new file mode 100644 index 00000000000..17ad7c90fbc --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Boolean.php @@ -0,0 +1,63 @@ +container[$offset]); @@ -396,6 +397,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -409,6 +411,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -425,6 +428,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Cat.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Cat.php index 6029e0ffd55..71d8589c83f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Cat.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Cat.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -228,6 +228,7 @@ public function setDeclawed($declawed) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -240,6 +241,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -253,6 +255,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -269,6 +272,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Category.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Category.php index 5a7416875f2..40f94dae4ef 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Category.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Category.php @@ -13,12 +13,12 @@ /** * Swagger Petstore * - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -36,7 +36,6 @@ * Category Class Doc Comment * * @category Class - * @description A category for a pet * @package Swagger\Client * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen @@ -265,6 +264,7 @@ public function setName($name) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -277,6 +277,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -290,6 +291,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -306,6 +308,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ClassModel.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ClassModel.php index 32c18564255..d42cfc0925a 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ClassModel.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ClassModel.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -235,6 +235,7 @@ public function setClass($_class) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -247,6 +248,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -260,6 +262,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -276,6 +279,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Client.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Client.php index c69e66abf91..0bd3cb11df5 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Client.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Client.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -234,6 +234,7 @@ public function setClient($client) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -246,6 +247,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -259,6 +261,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -275,6 +278,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Dog.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Dog.php index a291dfc0310..17cfac809fb 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Dog.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Dog.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -228,6 +228,7 @@ public function setBreed($breed) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -240,6 +241,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -253,6 +255,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -269,6 +272,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/EnumArrays.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/EnumArrays.php index 819caf87933..9d6edb75485 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/EnumArrays.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/EnumArrays.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -320,6 +320,7 @@ public function setArrayEnum($array_enum) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -332,6 +333,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -345,6 +347,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -361,6 +364,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/EnumClass.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/EnumClass.php index e7e7c94c153..c5878e6d39c 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/EnumClass.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/EnumClass.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/EnumTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/EnumTest.php index 146660c23fa..74effb4f178 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/EnumTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/EnumTest.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -489,6 +489,7 @@ public function setOuterEnum($outer_enum) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -501,6 +502,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -514,6 +516,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -530,6 +533,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/FormatTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/FormatTest.php index 32f17e62537..e38d38430be 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/FormatTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/FormatTest.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -719,6 +719,7 @@ public function setPassword($password) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -731,6 +732,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -744,6 +746,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -760,6 +763,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/HasOnlyReadOnly.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/HasOnlyReadOnly.php index 4cec0bd4d9a..b019619b179 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/HasOnlyReadOnly.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/HasOnlyReadOnly.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -264,6 +264,7 @@ public function setFoo($foo) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -276,6 +277,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -289,6 +291,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -305,6 +308,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/MapTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/MapTest.php index 8d5e693736d..dbb87bc06d9 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/MapTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/MapTest.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -288,6 +288,7 @@ public function setMapOfEnumString($map_of_enum_string) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -300,6 +301,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -313,6 +315,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -329,6 +332,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/MixedPropertiesAndAdditionalPropertiesClass.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/MixedPropertiesAndAdditionalPropertiesClass.php index 66bfc7162ea..8dbe448f32d 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/MixedPropertiesAndAdditionalPropertiesClass.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/MixedPropertiesAndAdditionalPropertiesClass.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -294,6 +294,7 @@ public function setMap($map) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -306,6 +307,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -319,6 +321,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -335,6 +338,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Model200Response.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Model200Response.php index c3c8d7e28f9..2cfa077f844 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Model200Response.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Model200Response.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -265,6 +265,7 @@ public function setClass($class) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -277,6 +278,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -290,6 +292,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -306,6 +309,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelInterface.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelInterface.php index 497546b0633..e1408238ba0 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelInterface.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelInterface.php @@ -13,12 +13,12 @@ /** * Swagger Petstore * - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelList.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelList.php index 6be35c1b746..375bf310e8a 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelList.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelList.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -234,6 +234,7 @@ public function set123List($_123_list) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -246,6 +247,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -259,6 +261,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -275,6 +278,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelReturn.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelReturn.php index 12008802e64..e08e1912157 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelReturn.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelReturn.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -235,6 +235,7 @@ public function setReturn($return) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -247,6 +248,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -260,6 +262,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -276,6 +279,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php index e8ea7b79a6b..87705fcb6d8 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -328,6 +328,7 @@ public function set123Number($_123_number) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -340,6 +341,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -353,6 +355,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -369,6 +372,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/NumberOnly.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/NumberOnly.php index 6652f04fc23..5dffecc0bcf 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/NumberOnly.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/NumberOnly.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -234,6 +234,7 @@ public function setJustNumber($just_number) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -246,6 +247,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -259,6 +261,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -275,6 +278,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Order.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Order.php index 8abed8e858e..94569457d08 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Order.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Order.php @@ -13,12 +13,12 @@ /** * Swagger Petstore * - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -36,7 +36,6 @@ * Order Class Doc Comment * * @category Class - * @description An order for a pets from the pet store * @package Swagger\Client * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen @@ -419,6 +418,7 @@ public function setComplete($complete) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -431,6 +431,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -444,6 +445,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -460,6 +462,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/OuterBoolean.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/OuterBoolean.php index da1371e3a49..fbbdccf8453 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/OuterBoolean.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/OuterBoolean.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -209,6 +209,7 @@ public function valid() * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -221,6 +222,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -234,6 +236,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -250,6 +253,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/OuterComposite.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/OuterComposite.php index a1e5bdf9e07..6c23f38a72c 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/OuterComposite.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/OuterComposite.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -294,6 +294,7 @@ public function setMyBoolean($my_boolean) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -306,6 +307,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -319,6 +321,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -335,6 +338,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/OuterEnum.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/OuterEnum.php index 3311c7fe705..79edabface6 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/OuterEnum.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/OuterEnum.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/OuterNumber.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/OuterNumber.php index 6016808d6e8..3c2a1dc0640 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/OuterNumber.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/OuterNumber.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -209,6 +209,7 @@ public function valid() * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -221,6 +222,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -234,6 +236,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -250,6 +253,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/OuterString.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/OuterString.php index e10da606d3a..311904480b9 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/OuterString.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/OuterString.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -209,6 +209,7 @@ public function valid() * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -221,6 +222,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -234,6 +236,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -250,6 +253,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Pet.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Pet.php index 2502e8b7e4d..a1769b5ec8a 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Pet.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Pet.php @@ -13,12 +13,12 @@ /** * Swagger Petstore * - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -36,7 +36,6 @@ * Pet Class Doc Comment * * @category Class - * @description A pet for sale in the pet store * @package Swagger\Client * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen @@ -425,6 +424,7 @@ public function setStatus($status) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -437,6 +437,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -450,6 +451,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -466,6 +468,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ReadOnlyFirst.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ReadOnlyFirst.php index 6e116507205..9ac3e712bf7 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ReadOnlyFirst.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ReadOnlyFirst.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -264,6 +264,7 @@ public function setBaz($baz) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -276,6 +277,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -289,6 +291,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -305,6 +308,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/SpecialModelName.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/SpecialModelName.php index e316c8d9b11..041ed270786 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/SpecialModelName.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/SpecialModelName.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -234,6 +234,7 @@ public function setSpecialPropertyName($special_property_name) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -246,6 +247,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -259,6 +261,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -275,6 +278,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Tag.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Tag.php index 3e6025e6eba..3191571c350 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Tag.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Tag.php @@ -13,12 +13,12 @@ /** * Swagger Petstore * - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -36,7 +36,6 @@ * Tag Class Doc Comment * * @category Class - * @description A tag for a pet * @package Swagger\Client * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen @@ -265,6 +264,7 @@ public function setName($name) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -277,6 +277,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -290,6 +291,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -306,6 +308,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/User.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/User.php index 1f9ddd22b37..c2312b0b400 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/User.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/User.php @@ -13,12 +13,12 @@ /** * Swagger Petstore * - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -36,7 +36,6 @@ * User Class Doc Comment * * @category Class - * @description A User who is purchasing from the pet store * @package Swagger\Client * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen @@ -445,6 +444,7 @@ public function setUserStatus($user_status) * * @return boolean */ + #[\ReturnTypeWillChange] public function offsetExists($offset) { return isset($this->container[$offset]); @@ -457,6 +457,7 @@ public function offsetExists($offset) * * @return mixed */ + #[\ReturnTypeWillChange] public function offsetGet($offset) { return isset($this->container[$offset]) ? $this->container[$offset] : null; @@ -470,6 +471,7 @@ public function offsetGet($offset) * * @return void */ + #[\ReturnTypeWillChange] public function offsetSet($offset, $value) { if (is_null($offset)) { @@ -486,6 +488,7 @@ public function offsetSet($offset, $value) * * @return void */ + #[\ReturnTypeWillChange] public function offsetUnset($offset) { unset($this->container[$offset]); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php index c2148b2a923..5b613f84e6c 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php @@ -13,12 +13,12 @@ /** * Swagger Petstore * - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** diff --git a/samples/client/petstore/php/SwaggerClient-php/phpunit.xml.dist b/samples/client/petstore/php/SwaggerClient-php/phpunit.xml.dist index cadedbc2469..c12ee148477 100644 --- a/samples/client/petstore/php/SwaggerClient-php/phpunit.xml.dist +++ b/samples/client/petstore/php/SwaggerClient-php/phpunit.xml.dist @@ -14,8 +14,8 @@ - ./lib\Api - ./lib\Model + ./lib/Api + ./lib/Model diff --git a/samples/client/petstore/php/SwaggerClient-php/test/Api/AnotherFakeApiTest.php b/samples/client/petstore/php/SwaggerClient-php/test/Api/AnotherFakeApiTest.php index 48c09a2ce97..ad4debd96e7 100644 --- a/samples/client/petstore/php/SwaggerClient-php/test/Api/AnotherFakeApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/test/Api/AnotherFakeApiTest.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -40,34 +40,34 @@ * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen */ -class AnotherFakeApiTest extends \PHPUnit_Framework_TestCase +class AnotherFakeApiTest extends \PHPUnit\Framework\TestCase { /** * Setup before running any test cases */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { } /** * Setup before running each test case */ - public function setUp() + public function setUp(): void { } /** * Clean up after running each test case */ - public function tearDown() + public function tearDown(): void { } /** * Clean up after running all test cases */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { } diff --git a/samples/client/petstore/php/SwaggerClient-php/test/Api/FakeApiTest.php b/samples/client/petstore/php/SwaggerClient-php/test/Api/FakeApiTest.php index dec5918dcba..cd52685ae75 100644 --- a/samples/client/petstore/php/SwaggerClient-php/test/Api/FakeApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/test/Api/FakeApiTest.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -40,34 +40,34 @@ * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen */ -class FakeApiTest extends \PHPUnit_Framework_TestCase +class FakeApiTest extends \PHPUnit\Framework\TestCase { /** * Setup before running any test cases */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { } /** * Setup before running each test case */ - public function setUp() + public function setUp(): void { } /** * Clean up after running each test case */ - public function tearDown() + public function tearDown(): void { } /** * Clean up after running all test cases */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { } diff --git a/samples/client/petstore/php/SwaggerClient-php/test/Api/FakeClassnameTags123ApiTest.php b/samples/client/petstore/php/SwaggerClient-php/test/Api/FakeClassnameTags123ApiTest.php index 5c1a24eb5c4..5a19bf9982f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/test/Api/FakeClassnameTags123ApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/test/Api/FakeClassnameTags123ApiTest.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -40,34 +40,34 @@ * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen */ -class FakeClassnameTags123ApiTest extends \PHPUnit_Framework_TestCase +class FakeClassnameTags123ApiTest extends \PHPUnit\Framework\TestCase { /** * Setup before running any test cases */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { } /** * Setup before running each test case */ - public function setUp() + public function setUp(): void { } /** * Clean up after running each test case */ - public function tearDown() + public function tearDown(): void { } /** * Clean up after running all test cases */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { } diff --git a/samples/client/petstore/php/SwaggerClient-php/test/Api/PetApiTest.php b/samples/client/petstore/php/SwaggerClient-php/test/Api/PetApiTest.php index 892e30c3171..ca98966f580 100644 --- a/samples/client/petstore/php/SwaggerClient-php/test/Api/PetApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/test/Api/PetApiTest.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -40,34 +40,34 @@ * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen */ -class PetApiTest extends \PHPUnit_Framework_TestCase +class PetApiTest extends \PHPUnit\Framework\TestCase { /** * Setup before running any test cases */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { } /** * Setup before running each test case */ - public function setUp() + public function setUp(): void { } /** * Clean up after running each test case */ - public function tearDown() + public function tearDown(): void { } /** * Clean up after running all test cases */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { } diff --git a/samples/client/petstore/php/SwaggerClient-php/test/Api/StoreApiTest.php b/samples/client/petstore/php/SwaggerClient-php/test/Api/StoreApiTest.php index c186432170e..bf130507bf2 100644 --- a/samples/client/petstore/php/SwaggerClient-php/test/Api/StoreApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/test/Api/StoreApiTest.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -40,34 +40,34 @@ * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen */ -class StoreApiTest extends \PHPUnit_Framework_TestCase +class StoreApiTest extends \PHPUnit\Framework\TestCase { /** * Setup before running any test cases */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { } /** * Setup before running each test case */ - public function setUp() + public function setUp(): void { } /** * Clean up after running each test case */ - public function tearDown() + public function tearDown(): void { } /** * Clean up after running all test cases */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { } diff --git a/samples/client/petstore/php/SwaggerClient-php/test/Api/UserApiTest.php b/samples/client/petstore/php/SwaggerClient-php/test/Api/UserApiTest.php index 822e6b84b7f..fe609dd8965 100644 --- a/samples/client/petstore/php/SwaggerClient-php/test/Api/UserApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/test/Api/UserApiTest.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -40,34 +40,34 @@ * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen */ -class UserApiTest extends \PHPUnit_Framework_TestCase +class UserApiTest extends \PHPUnit\Framework\TestCase { /** * Setup before running any test cases */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { } /** * Setup before running each test case */ - public function setUp() + public function setUp(): void { } /** * Clean up after running each test case */ - public function tearDown() + public function tearDown(): void { } /** * Clean up after running all test cases */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { } diff --git a/samples/client/petstore/php/SwaggerClient-php/test/Model/AdditionalPropertiesClassTest.php b/samples/client/petstore/php/SwaggerClient-php/test/Model/AdditionalPropertiesClassTest.php index 8ffddf14cc9..a359ea0b8c8 100644 --- a/samples/client/petstore/php/SwaggerClient-php/test/Model/AdditionalPropertiesClassTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/test/Model/AdditionalPropertiesClassTest.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -38,34 +38,34 @@ * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen */ -class AdditionalPropertiesClassTest extends \PHPUnit_Framework_TestCase +class AdditionalPropertiesClassTest extends \PHPUnit\Framework\TestCase { /** * Setup before running any test case */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { } /** * Setup before running each test case */ - public function setUp() + public function setUp(): void { } /** * Clean up after running each test case */ - public function tearDown() + public function tearDown(): void { } /** * Clean up after running all test cases */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { } diff --git a/samples/client/petstore/php/SwaggerClient-php/test/Model/AnimalFarmTest.php b/samples/client/petstore/php/SwaggerClient-php/test/Model/AnimalFarmTest.php index 69f3552d76b..ad464737a86 100644 --- a/samples/client/petstore/php/SwaggerClient-php/test/Model/AnimalFarmTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/test/Model/AnimalFarmTest.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -38,34 +38,34 @@ * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen */ -class AnimalFarmTest extends \PHPUnit_Framework_TestCase +class AnimalFarmTest extends \PHPUnit\Framework\TestCase { /** * Setup before running any test case */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { } /** * Setup before running each test case */ - public function setUp() + public function setUp(): void { } /** * Clean up after running each test case */ - public function tearDown() + public function tearDown(): void { } /** * Clean up after running all test cases */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { } diff --git a/samples/client/petstore/php/SwaggerClient-php/test/Model/AnimalTest.php b/samples/client/petstore/php/SwaggerClient-php/test/Model/AnimalTest.php index 9e640ebe0fe..93eea76ceeb 100644 --- a/samples/client/petstore/php/SwaggerClient-php/test/Model/AnimalTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/test/Model/AnimalTest.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -38,34 +38,34 @@ * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen */ -class AnimalTest extends \PHPUnit_Framework_TestCase +class AnimalTest extends \PHPUnit\Framework\TestCase { /** * Setup before running any test case */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { } /** * Setup before running each test case */ - public function setUp() + public function setUp(): void { } /** * Clean up after running each test case */ - public function tearDown() + public function tearDown(): void { } /** * Clean up after running all test cases */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { } diff --git a/samples/client/petstore/php/SwaggerClient-php/test/Model/ApiResponseTest.php b/samples/client/petstore/php/SwaggerClient-php/test/Model/ApiResponseTest.php index d4a63e88b34..e7089cf7830 100644 --- a/samples/client/petstore/php/SwaggerClient-php/test/Model/ApiResponseTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/test/Model/ApiResponseTest.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -38,34 +38,34 @@ * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen */ -class ApiResponseTest extends \PHPUnit_Framework_TestCase +class ApiResponseTest extends \PHPUnit\Framework\TestCase { /** * Setup before running any test case */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { } /** * Setup before running each test case */ - public function setUp() + public function setUp(): void { } /** * Clean up after running each test case */ - public function tearDown() + public function tearDown(): void { } /** * Clean up after running all test cases */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { } diff --git a/samples/client/petstore/php/SwaggerClient-php/test/Model/ArrayOfArrayOfNumberOnlyTest.php b/samples/client/petstore/php/SwaggerClient-php/test/Model/ArrayOfArrayOfNumberOnlyTest.php index 779186ca795..32aa3ccf7be 100644 --- a/samples/client/petstore/php/SwaggerClient-php/test/Model/ArrayOfArrayOfNumberOnlyTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/test/Model/ArrayOfArrayOfNumberOnlyTest.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -38,34 +38,34 @@ * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen */ -class ArrayOfArrayOfNumberOnlyTest extends \PHPUnit_Framework_TestCase +class ArrayOfArrayOfNumberOnlyTest extends \PHPUnit\Framework\TestCase { /** * Setup before running any test case */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { } /** * Setup before running each test case */ - public function setUp() + public function setUp(): void { } /** * Clean up after running each test case */ - public function tearDown() + public function tearDown(): void { } /** * Clean up after running all test cases */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { } diff --git a/samples/client/petstore/php/SwaggerClient-php/test/Model/ArrayOfNumberOnlyTest.php b/samples/client/petstore/php/SwaggerClient-php/test/Model/ArrayOfNumberOnlyTest.php index 332a1d8988a..51beb225876 100644 --- a/samples/client/petstore/php/SwaggerClient-php/test/Model/ArrayOfNumberOnlyTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/test/Model/ArrayOfNumberOnlyTest.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -38,34 +38,34 @@ * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen */ -class ArrayOfNumberOnlyTest extends \PHPUnit_Framework_TestCase +class ArrayOfNumberOnlyTest extends \PHPUnit\Framework\TestCase { /** * Setup before running any test case */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { } /** * Setup before running each test case */ - public function setUp() + public function setUp(): void { } /** * Clean up after running each test case */ - public function tearDown() + public function tearDown(): void { } /** * Clean up after running all test cases */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { } diff --git a/samples/client/petstore/php/SwaggerClient-php/test/Model/ArrayTestTest.php b/samples/client/petstore/php/SwaggerClient-php/test/Model/ArrayTestTest.php index d9e06a9b584..61e4a8970a3 100644 --- a/samples/client/petstore/php/SwaggerClient-php/test/Model/ArrayTestTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/test/Model/ArrayTestTest.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * Swagger Codegen version: 2.4.3-SNAPSHOT + * Swagger Codegen version: 2.4.53-SNAPSHOT */ /** @@ -38,34 +38,34 @@ * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen */ -class ArrayTestTest extends \PHPUnit_Framework_TestCase +class ArrayTestTest extends \PHPUnit\Framework\TestCase { /** * Setup before running any test case */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { } /** * Setup before running each test case */ - public function setUp() + public function setUp(): void { } /** * Clean up after running each test case */ - public function tearDown() + public function tearDown(): void { } /** * Clean up after running all test cases */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { } diff --git a/samples/client/petstore/php/SwaggerClient-php/test/Model/BooleanTest.php b/samples/client/petstore/php/SwaggerClient-php/test/Model/BooleanTest.php new file mode 100644 index 00000000000..6cdd5ce2eb4 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/test/Model/BooleanTest.php @@ -0,0 +1,78 @@ +api = new Api\PetApi(); @@ -57,13 +57,13 @@ public function testAsyncRequestWithHttpInfo() list($pet, $status, $headers) = $promise->wait(); $this->assertEquals(200, $status); - $this->assertInternalType('array', $headers); + $this->assertIsArray($headers); $this->assertInstanceOf(Pet::class, $pet); } public function testAsyncThrowingException() { - $this->setExpectedException(ApiException::class); + $this->expectException(ApiException::class); $promise = $this->api->getPetByIdAsync(0); $promise->wait(); @@ -77,7 +77,7 @@ public function testAsyncApiExceptionWithoutWaitIsNotThrown() public function testAsyncHttpInfoThrowingException() { - $this->setExpectedException(ApiException::class); + $this->expectException(ApiException::class); $promise = $this->api->getPetByIdAsyncWithHttpInfo(0); $promise->wait(); diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/AuthTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/AuthTest.php index d0204352558..1ba3624651f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/AuthTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/AuthTest.php @@ -8,7 +8,7 @@ require_once __DIR__ . '/FakeHttpClient.php'; -class AuthTest extends \PHPUnit_Framework_TestCase +class AuthTest extends \PHPUnit\Framework\TestCase { public function testCustomApiKeyHeader() { diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/DateTimeSerializerTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/DateTimeSerializerTest.php index cea8db4a067..75f122666dc 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/DateTimeSerializerTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/DateTimeSerializerTest.php @@ -4,7 +4,7 @@ use Swagger\Client\Model\FormatTest; -class DateTimeSerializerTest extends \PHPUnit_Framework_TestCase +class DateTimeSerializerTest extends \PHPUnit\Framework\TestCase { public function testDateTimeSanitazion() { diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/DebugTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/DebugTest.php index 6eb9dacaffe..6395b1b0e7b 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/DebugTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/DebugTest.php @@ -1,7 +1,7 @@ assertSame($expected, $enum->listInvalidProperties()); } - /** - * @expectedException \InvalidArgumentException - */ public function testThrowExceptionWhenInvalidAmbiguousValueHasPassed() { + $this->expectException(\InvalidArgumentException::class); $enum = new EnumTest(); $enum->setEnumString(0); } diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/ExceptionTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/ExceptionTest.php index 29a0d5d7559..acb0c2bb59b 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/ExceptionTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/ExceptionTest.php @@ -4,15 +4,13 @@ use GuzzleHttp\Client; -class ExceptionTest extends \PHPUnit_Framework_TestCase +class ExceptionTest extends \PHPUnit\Framework\TestCase { - /** - * @expectedException \Swagger\Client\ApiException - * @expectedExceptionCode 404 - * @expectedExceptionMessage http://petstore.swagger.io/INVALID_URL/store/inventory - */ public function testNotFound() { + $this->expectException(\Swagger\Client\ApiException::class); + $this->expectExceptionCode(404); + $this->expectExceptionMessage('http://petstore.swagger.io/INVALID_URL/store/inventory'); $config = new Configuration(); $config->setHost('http://petstore.swagger.io/INVALID_URL'); @@ -23,12 +21,10 @@ public function testNotFound() $api->getInventory(); } - /** - * @expectedException \Swagger\Client\ApiException - * @expectedExceptionMessage Could not resolve host - */ public function testWrongHost() { + $this->expectException(\Swagger\Client\ApiException::class); + $this->expectExceptionMessage('Could not resolve host'); $config = new Configuration(); $config->setHost('http://wrong_host.zxc'); diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/FakeHttpClient.php b/samples/client/petstore/php/SwaggerClient-php/tests/FakeHttpClient.php index abdfa7cf7c2..774ba5a5f4f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/FakeHttpClient.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/FakeHttpClient.php @@ -4,6 +4,7 @@ use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\GuzzleException; +use GuzzleHttp\Promise\PromiseInterface; use GuzzleHttp\Psr7\Response; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -26,7 +27,7 @@ public function getLastRequest() /** * @param null|ResponseInterface $response */ - public function setResponse(ResponseInterface $response = null) + public function setResponse(?ResponseInterface $response = null) { $this->response = $response; } @@ -41,23 +42,23 @@ public function setResponse(ResponseInterface $response = null) * @return ResponseInterface * @throws GuzzleException */ - public function send(RequestInterface $request, array $options = []) + public function send(RequestInterface $request, array $options = []): ResponseInterface { $this->request = $request; return $this->response ?: new Response(200); } - public function sendAsync(RequestInterface $request, array $options = []) + public function sendAsync(RequestInterface $request, array $options = []): PromiseInterface { throw new \RuntimeException('not implemented'); } - public function request($method, $uri, array $options = []) + public function request(string $method, $uri, array $options = []): ResponseInterface { throw new \RuntimeException('not implemented'); } - public function requestAsync($method, $uri, array $options = []) + public function requestAsync(string $method, $uri, array $options = []): PromiseInterface { throw new \RuntimeException('not implemented'); } diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/FormatTestTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/FormatTestTest.php index e91222a1686..2e8ced07561 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/FormatTestTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/FormatTestTest.php @@ -2,7 +2,7 @@ use Swagger\Client\Model\FormatTest; -class FormatTestTest extends \PHPUnit_Framework_TestCase +class FormatTestTest extends \PHPUnit\Framework\TestCase { public function testCountTheLengthOfMultiByteStringsCorrectly() { diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/HeaderSelectorTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/HeaderSelectorTest.php index 7a89448f89e..eaf4958544d 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/HeaderSelectorTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/HeaderSelectorTest.php @@ -2,7 +2,7 @@ namespace Swagger\Client; -class HeaderSelectorTest extends \PHPUnit_Framework_TestCase +class HeaderSelectorTest extends \PHPUnit\Framework\TestCase { public function testSelectingHeaders() { diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/HeadersTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/HeadersTest.php index 5431a912efe..a3dc4c96ce8 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/HeadersTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/HeadersTest.php @@ -4,12 +4,12 @@ require_once __DIR__ . '/FakeHttpClient.php'; -class HeadersTest extends \PHPUnit_Framework_TestCase +class HeadersTest extends \PHPUnit\Framework\TestCase { /** @var FakeHttpClient */ private $fakeHttpClient; - public function setUp() + public function setUp(): void { $this->fakeHttpClient = new FakeHttpClient(); } diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/ModelInheritanceTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/ModelInheritanceTest.php index 658e60ba638..4b8fc4a2d73 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/ModelInheritanceTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/ModelInheritanceTest.php @@ -12,7 +12,7 @@ * * @package Swagger\Client */ -class ModelInheritanceTest extends \PHPUnit_Framework_TestCase +class ModelInheritanceTest extends \PHPUnit\Framework\TestCase { /** * test if default values works diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/ObjectSerializerTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/ObjectSerializerTest.php index e81f5b03fc2..3dfb13b669b 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/ObjectSerializerTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/ObjectSerializerTest.php @@ -3,7 +3,7 @@ namespace Swagger\Client; // test object serializer -class ObjectSerializerTest extends \PHPUnit_Framework_TestCase +class ObjectSerializerTest extends \PHPUnit\Framework\TestCase { /** * Test the sanitizeForSerialization method with a stdClass. diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/OrderApiTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/OrderApiTest.php index 8b5c8f7e499..2ca4c30c77b 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/OrderApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/OrderApiTest.php @@ -2,11 +2,11 @@ namespace Swagger\Client; -class OrderApiTest extends \PHPUnit_Framework_TestCase +class OrderApiTest extends \PHPUnit\Framework\TestCase { // add a new pet (id 10005) to ensure the pet object is available for all the tests - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { // for error reporting (need to run with php5.3 to get no warning) //ini_set('display_errors', 1); @@ -30,11 +30,9 @@ public function testOrder() $this->assertSame("placed", $order->getStatus()); } - /** - * @expectedException InvalidArgumentException - */ public function testOrderException() { + $this->expectException(\InvalidArgumentException::class); // initialize the API client $order = new Model\Order(); $order->setStatus("invalid_value"); diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/OuterEnumTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/OuterEnumTest.php index d7d12d5cbb8..5a9581f104c 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/OuterEnumTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/OuterEnumTest.php @@ -5,7 +5,7 @@ use Swagger\Client\Model\EnumTest; use Swagger\Client\Model\OuterEnum; -class OuterEnumTest extends \PHPUnit_Framework_TestCase +class OuterEnumTest extends \PHPUnit\Framework\TestCase { public function testDeserialize() { @@ -14,13 +14,13 @@ public function testDeserialize() OuterEnum::class ); - $this->assertInternalType('string', $result); + $this->assertIsString($result); $this->assertEquals('placed', $result); } public function testDeserializeInvalidValue() { - $this->setExpectedException(\InvalidArgumentException::class, 'Invalid value for enum'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid value for enum'); ObjectSerializer::deserialize( "lkjfalgkdfjg", @@ -55,7 +55,7 @@ public function testSanitize() $json ); - $this->assertInternalType('string', $result); + $this->assertIsString($result); } public function testSanitizeNested() @@ -71,16 +71,16 @@ public function testSanitizeNested() $input ); - $this->assertInternalType('object', $result); + $this->assertIsObject($result); $this->assertInstanceOf(\stdClass::class, $result); - $this->assertInternalType('string', $result->outerEnum); + $this->assertIsString($result->outerEnum); $this->assertEquals('approved', $result->outerEnum); } public function testSanitizeNestedInvalidValue() { - $this->setExpectedException(\InvalidArgumentException::class, 'Invalid value for enum'); + $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid value for enum'); $input = new EnumTest([ 'enum_string' => 'UPPER', diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/ParametersTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/ParametersTest.php index 37877556d01..e5dc3fcaa49 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/ParametersTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/ParametersTest.php @@ -7,7 +7,7 @@ require_once __DIR__ . '/FakeHttpClient.php'; -class ParametersTest extends \PHPUnit_Framework_TestCase +class ParametersTest extends \PHPUnit\Framework\TestCase { /** @var FakeHttpClient */ private $fakeHttpClient; @@ -16,7 +16,7 @@ class ParametersTest extends \PHPUnit_Framework_TestCase /** @var UserApi */ private $userApi; - public function setUp() + public function setUp(): void { $this->fakeHttpClient = new FakeHttpClient(); $this->fakeApi = new Api\FakeApi($this->fakeHttpClient); diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php index 1cfad6aaeae..46f5e962c2c 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php @@ -6,14 +6,14 @@ use Swagger\Client\Model\ApiResponse; use Swagger\Client\Model\Pet; -class PetApiTest extends \PHPUnit_Framework_TestCase +class PetApiTest extends \PHPUnit\Framework\TestCase { /** @var PetApi */ private $api; // add a new pet (id 10005) to ensure the pet object is available for all the tests - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { // increase memory limit to avoid fatal error due to findPetByStatus // returning a lot of data @@ -45,10 +45,10 @@ public static function setUpBeforeClass() // add a new pet (model) list(, $status) = $petApi->addPetWithHttpInfo($newPet); - \PHPUnit_Framework_Assert::assertEquals(200, $status); + \PHPUnit\Framework\Assert::assertEquals(200, $status); } - public function setUp() + public function setUp(): void { $this->api = new Api\PetApi(); } @@ -86,7 +86,7 @@ public function testGetPetById() * $this->assertSame($response->getPhotoUrls()[0], 'http://test_php_unit_test.com'); * * // category is type "object" - * $this->assertInternalType('array', $response->getCategory()); + * $this->assertIsArray($response->getCategory()); * $this->assertSame($response->getCategory()['id'], $pet_id); * $this->assertSame($response->getCategory()['name'], 'test php category'); * @@ -278,7 +278,7 @@ public function testGetPetByIdWithByteArray() $bytes = $pet_api->petPetIdtestingByteArraytrueGet($pet_id); $json = json_decode($bytes, true); - $this->assertInternalType("string", $bytes); + $this->assertIsString($bytes); $this->assertSame($json['id'], $pet_id); // not testing name as it's tested by addPetUsingByteArray @@ -375,12 +375,11 @@ public function testDefaultValues() /** * test invalid argument - * - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Missing the required parameter $status when calling findPetsByStatus */ public function testInvalidArgument() { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Missing the required parameter $status when calling findPetsByStatus'); // the argument is required, and we must specify one or some from 'available', 'pending', 'sold' $this->api->findPetsByStatus([]); } diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/PetTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/PetTest.php index 60ce604c522..7ddb44622ca 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/PetTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/PetTest.php @@ -4,7 +4,7 @@ use Swagger\Client\Model\Pet; -class PetTest extends \PHPUnit_Framework_TestCase +class PetTest extends \PHPUnit\Framework\TestCase { /** * test empty object serialization diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/RequestTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/RequestTest.php index 779ae71ab02..66a89df974a 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/RequestTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/RequestTest.php @@ -4,7 +4,7 @@ use Swagger\Client\Api\FakeApi; -class RequestTest extends \PHPUnit_Framework_TestCase +class RequestTest extends \PHPUnit\Framework\TestCase { /** @var FakeApi */ @@ -12,7 +12,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase /** @var FakeHttpClient */ private $fakeClient; - public function setUp() + public function setUp(): void { $this->fakeClient = new FakeHttpClient(); $this->api = new Api\FakeApi($this->fakeClient); diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/ResponseTypesTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/ResponseTypesTest.php index 71eda338ba9..6b2257e5073 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/ResponseTypesTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/ResponseTypesTest.php @@ -8,14 +8,14 @@ require_once __DIR__ . '/FakeHttpClient.php'; -class ResponseTypesTest extends \PHPUnit_Framework_TestCase +class ResponseTypesTest extends \PHPUnit\Framework\TestCase { /** @var PetApi */ private $api; /** @var FakeHttpClient */ private $fakeHttpClient; - public function setUp() + public function setUp(): void { $this->fakeHttpClient = new FakeHttpClient(); $this->api = new PetApi($this->fakeHttpClient); @@ -37,12 +37,10 @@ public function testDefault2xxReturnType() $this->assertInstanceOf(Pet::class, $result); } - /** - * @expectedException \Swagger\Client\ApiException - * @expectedExceptionCode 400 - */ public function testDefinedErrorException() { + $this->expectException(\Swagger\Client\ApiException::class); + $this->expectExceptionCode(400); $statusCode = 400; $this->fakeHttpClient->setResponse(new Response($statusCode, [], '{}')); @@ -68,12 +66,10 @@ public function testDefinedErrorException() // $this->assertInstanceOf(Error::class, $result); // } - /** - * @expectedException \Swagger\Client\ApiException - * @expectedExceptionCode 404 - */ public function testDefaultErrorException() { + $this->expectException(\Swagger\Client\ApiException::class); + $this->expectExceptionCode(404); $statusCode = 404; $this->fakeHttpClient->setResponse(new Response($statusCode, [], '{}')); diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php index 3af84b8d851..6be4d931bee 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php @@ -8,12 +8,12 @@ use Swagger\Client\Model\Pet; use Swagger\Client\Model\Tag; -class StoreApiTest extends \PHPUnit_Framework_TestCase +class StoreApiTest extends \PHPUnit\Framework\TestCase { /** @var StoreApi */ private $api; - public function setUp() + public function setUp(): void { $this->api = new StoreApi(); } @@ -21,7 +21,7 @@ public function setUp() /** * Setup before running each test case */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { // add a new pet (id 10005) to ensure the pet object is available for all the tests // new pet @@ -50,7 +50,7 @@ public function testGetInventory() { $result = $this->api->getInventory(); - $this->assertInternalType('array', $result); - $this->assertInternalType('int', $result['available']); + $this->assertIsArray($result); + $this->assertIsInt($result['available']); } } diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/UserApiTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/UserApiTest.php index fdaf42467e1..9283c6e7337 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/UserApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/UserApiTest.php @@ -4,13 +4,13 @@ use Swagger\Client\Api\UserApi; -class UserApiTest extends \PHPUnit_Framework_TestCase +class UserApiTest extends \PHPUnit\Framework\TestCase { /** @var UserApi*/ private $api; - public function setUp() + public function setUp(): void { $this->api = new Api\UserApi(); } @@ -22,7 +22,7 @@ public function testLoginUser() // login $response = $this->api->loginUser('xxxxx', 'yyyyyyyy'); - $this->assertInternalType('string', $response); + $this->assertIsString($response); $this->assertRegExp( '/logged in user session/', $response, diff --git a/samples/server/petstore/php-symfony/.swagger-codegen/VERSION b/samples/server/petstore/php-symfony/.swagger-codegen/VERSION index 0e6df709793..bab531eaf33 100644 --- a/samples/server/petstore/php-symfony/.swagger-codegen/VERSION +++ b/samples/server/petstore/php-symfony/.swagger-codegen/VERSION @@ -1 +1 @@ -2.4.5-SNAPSHOT \ No newline at end of file +2.4.53-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/composer.json b/samples/server/petstore/php-symfony/SymfonyBundle-php/composer.json index 1834f482225..2001aa4aa19 100644 --- a/samples/server/petstore/php-symfony/SymfonyBundle-php/composer.json +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/composer.json @@ -27,7 +27,7 @@ "require-dev": { "phpunit/phpunit": "~4.8", "satooshi/php-coveralls": "~1.0", - "squizlabs/php_codesniffer": "~2.6", + "squizlabs/php_codesniffer": "^3.0", "friendsofphp/php-cs-fixer": "~1.12", "symfony/browser-kit": "*", "hoa/regex": "~1.0"