diff --git a/modules/swagger-codegen/src/main/resources/php/api.mustache b/modules/swagger-codegen/src/main/resources/php/api.mustache index 22ae27fc77..cce59f4d94 100644 --- a/modules/swagger-codegen/src/main/resources/php/api.mustache +++ b/modules/swagger-codegen/src/main/resources/php/api.mustache @@ -184,14 +184,14 @@ use \{{invokerPackage}}\ObjectSerializer; {{#authMethods}}{{#isApiKey}} // this endpoint requires API key authentication $apiKey = $this->apiClient->getApiKeyWithPrefix('{{keyParamName}}'); - if ($apiKey !== null) { + if (strlen($apiKey) !== 0) { {{#isKeyInHeader}}$headerParams['{{keyParamName}}'] = $apiKey;{{/isKeyInHeader}}{{#isKeyInQuery}}$queryParams['{{keyParamName}}'] = $apiKey;{{/isKeyInQuery}} }{{/isApiKey}} {{#isBasic}}// this endpoint requires HTTP basic authentication - if ($this->apiClient->getConfig()->getUsername() !== null or $this->apiClient->getConfig()->getPassword() !== null) { + if (strlen($this->apiClient->getConfig()->getUsername()) !== 0 or strlen($this->apiClient->getConfig()->getPassword()) !== 0) { $headerParams['Authorization'] = 'Basic ' . base64_encode($this->apiClient->getConfig()->getUsername() . ":" . $this->apiClient->getConfig()->getPassword()); }{{/isBasic}}{{#isOAuth}}// this endpoint requires OAuth (access token) - if ($this->apiClient->getConfig()->getAccessToken() !== null) { + if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); }{{/isOAuth}} {{/authMethods}} 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 18aeba6407..bd82444f4f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -152,7 +152,7 @@ class PetApi } // this endpoint requires OAuth (access token) - if ($this->apiClient->getConfig()->getAccessToken() !== null) { + if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); } @@ -235,7 +235,7 @@ class PetApi } // this endpoint requires OAuth (access token) - if ($this->apiClient->getConfig()->getAccessToken() !== null) { + if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); } @@ -317,7 +317,7 @@ class PetApi } // this endpoint requires OAuth (access token) - if ($this->apiClient->getConfig()->getAccessToken() !== null) { + if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); } @@ -407,7 +407,7 @@ class PetApi } // this endpoint requires OAuth (access token) - if ($this->apiClient->getConfig()->getAccessToken() !== null) { + if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); } @@ -506,7 +506,7 @@ class PetApi // this endpoint requires API key authentication $apiKey = $this->apiClient->getApiKeyWithPrefix('api_key'); - if ($apiKey !== null) { + if (strlen($apiKey) !== 0) { $headerParams['api_key'] = $apiKey; } @@ -621,7 +621,7 @@ class PetApi } // this endpoint requires OAuth (access token) - if ($this->apiClient->getConfig()->getAccessToken() !== null) { + if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); } @@ -716,7 +716,7 @@ class PetApi } // this endpoint requires OAuth (access token) - if ($this->apiClient->getConfig()->getAccessToken() !== null) { + if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); } @@ -828,7 +828,7 @@ class PetApi } // this endpoint requires OAuth (access token) - if ($this->apiClient->getConfig()->getAccessToken() !== null) { + if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); } 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 4539aeeeab..4faed9a36b 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php @@ -147,7 +147,7 @@ class StoreApi // this endpoint requires API key authentication $apiKey = $this->apiClient->getApiKeyWithPrefix('api_key'); - if ($apiKey !== null) { + if (strlen($apiKey) !== 0) { $headerParams['api_key'] = $apiKey; }