forked from loafle/openapi-generator-original
Regenerated PHP petstore sample.
This commit is contained in:
parent
d907822fa9
commit
47b2ae934b
@ -431,9 +431,6 @@ class PetApi
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//TODO support oauth
|
|
||||||
|
|
||||||
// make the API Call
|
// make the API Call
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -509,10 +506,16 @@ class PetApi
|
|||||||
}
|
}
|
||||||
// form params
|
// form params
|
||||||
if ($name !== null) {
|
if ($name !== null) {
|
||||||
|
|
||||||
|
|
||||||
$formParams['name'] = $this->apiClient->getSerializer()->toFormValue($name);
|
$formParams['name'] = $this->apiClient->getSerializer()->toFormValue($name);
|
||||||
|
|
||||||
}// form params
|
}// form params
|
||||||
if ($status !== null) {
|
if ($status !== null) {
|
||||||
|
|
||||||
|
|
||||||
$formParams['status'] = $this->apiClient->getSerializer()->toFormValue($status);
|
$formParams['status'] = $this->apiClient->getSerializer()->toFormValue($status);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -665,10 +668,22 @@ class PetApi
|
|||||||
}
|
}
|
||||||
// form params
|
// form params
|
||||||
if ($additional_metadata !== null) {
|
if ($additional_metadata !== null) {
|
||||||
|
|
||||||
|
|
||||||
$formParams['additionalMetadata'] = $this->apiClient->getSerializer()->toFormValue($additional_metadata);
|
$formParams['additionalMetadata'] = $this->apiClient->getSerializer()->toFormValue($additional_metadata);
|
||||||
|
|
||||||
}// form params
|
}// form params
|
||||||
if ($file !== null) {
|
if ($file !== null) {
|
||||||
$formParams['file'] = '@' . $this->apiClient->getSerializer()->toFormValue($file);
|
|
||||||
|
// PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax
|
||||||
|
// See: https://wiki.php.net/rfc/curl-file-upload
|
||||||
|
if (function_exists('curl_file_create')) {
|
||||||
|
$formParams['file'] = curl_file_create($this->apiClient->getSerializer()->toFormValue($file));
|
||||||
|
} else {
|
||||||
|
$formParams['file'] = '@' . $this->apiClient->getSerializer()->toFormValue($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -165,6 +165,12 @@ class ApiClient
|
|||||||
|
|
||||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
|
||||||
|
// disable SSL verification, if needed
|
||||||
|
if ($this->config->getSSLVerification() == false) {
|
||||||
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
|
||||||
|
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (! empty($queryParams)) {
|
if (! empty($queryParams)) {
|
||||||
$url = ($url . '?' . http_build_query($queryParams));
|
$url = ($url . '?' . http_build_query($queryParams));
|
||||||
}
|
}
|
||||||
@ -233,9 +239,14 @@ class ApiClient
|
|||||||
$data = $http_body;
|
$data = $http_body;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
$data = json_decode($http_body);
|
||||||
|
if (json_last_error() > 0) { // if response is a string
|
||||||
|
$data = $http_body;
|
||||||
|
}
|
||||||
|
|
||||||
throw new ApiException(
|
throw new ApiException(
|
||||||
"[".$response_info['http_code']."] Error connecting to the API ($url)",
|
"[".$response_info['http_code']."] Error connecting to the API ($url)",
|
||||||
$response_info['http_code'], $http_header, $http_body
|
$response_info['http_code'], $http_header, $data
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return array($data, $http_header);
|
return array($data, $http_header);
|
||||||
|
@ -47,8 +47,8 @@ class ApiException extends Exception
|
|||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The HTTP body of the server response.
|
* The HTTP body of the server response either as Json or string.
|
||||||
* @var string
|
* @var mixed
|
||||||
*/
|
*/
|
||||||
protected $responseBody;
|
protected $responseBody;
|
||||||
|
|
||||||
@ -67,9 +67,9 @@ class ApiException extends Exception
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param string $message Error message
|
* @param string $message Error message
|
||||||
* @param string $code HTTP status code
|
* @param int $code HTTP status code
|
||||||
* @param string $responseHeaders HTTP response header
|
* @param string $responseHeaders HTTP response header
|
||||||
* @param string $responseBody Deseralized response object
|
* @param mixed $responseBody HTTP body of the server response either as Json or string
|
||||||
*/
|
*/
|
||||||
public function __construct($message="", $code=0, $responseHeaders=null, $responseBody=null)
|
public function __construct($message="", $code=0, $responseHeaders=null, $responseBody=null)
|
||||||
{
|
{
|
||||||
@ -89,9 +89,9 @@ class ApiException extends Exception
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the HTTP response body
|
* Gets the HTTP body of the server response either as Json or string
|
||||||
*
|
*
|
||||||
* @return string HTTP response body
|
* @return mixed HTTP body of the server response either as Json or string
|
||||||
*/
|
*/
|
||||||
public function getResponseBody()
|
public function getResponseBody()
|
||||||
{
|
{
|
||||||
|
@ -126,6 +126,15 @@ class Configuration
|
|||||||
*/
|
*/
|
||||||
protected $tempFolderPath;
|
protected $tempFolderPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if SSL verification should be enabled or disabled.
|
||||||
|
*
|
||||||
|
* This is useful if the host uses a self-signed SSL certificate.
|
||||||
|
*
|
||||||
|
* @var boolean True if the certificate should be validated, false otherwise.
|
||||||
|
*/
|
||||||
|
protected $sslVerification = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
@ -418,6 +427,29 @@ class Configuration
|
|||||||
return $this->tempFolderPath;
|
return $this->tempFolderPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets if SSL verification should be enabled or disabled
|
||||||
|
*
|
||||||
|
* @param boolean $sslVerification True if the certificate should be validated, false otherwise
|
||||||
|
*
|
||||||
|
* @return Configuration
|
||||||
|
*/
|
||||||
|
public function setSSLVerification($sslVerification)
|
||||||
|
{
|
||||||
|
$this->sslVerification = $sslVerification;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets if SSL verification should be enabled or disabled
|
||||||
|
*
|
||||||
|
* @return boolean True if the certificate should be validated, false otherwise
|
||||||
|
*/
|
||||||
|
public function getSSLVerification()
|
||||||
|
{
|
||||||
|
return $this->sslVerification;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the default configuration instance
|
* Gets the default configuration instance
|
||||||
*
|
*
|
||||||
|
@ -193,7 +193,7 @@ class ObjectSerializer
|
|||||||
$deserialized = $values;
|
$deserialized = $values;
|
||||||
} elseif ($class === '\DateTime') {
|
} elseif ($class === '\DateTime') {
|
||||||
$deserialized = new \DateTime($data);
|
$deserialized = new \DateTime($data);
|
||||||
} elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) {
|
} elseif (in_array($class, array('void', 'bool', 'string', 'double', 'byte', 'mixed', 'integer', 'float', 'int', 'DateTime', 'number', 'boolean', 'object'))) {
|
||||||
settype($data, $class);
|
settype($data, $class);
|
||||||
$deserialized = $data;
|
$deserialized = $data;
|
||||||
} elseif ($class === '\SplFileObject') {
|
} elseif ($class === '\SplFileObject') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user