forked from loafle/openapi-generator-original
add test case for default header
This commit is contained in:
parent
83d069d053
commit
8d708c2442
@ -182,7 +182,7 @@ class APIClient {
|
|||||||
$this->updateParamsForAuth($headerParams, $queryParams, $authSettings);
|
$this->updateParamsForAuth($headerParams, $queryParams, $authSettings);
|
||||||
|
|
||||||
# construct the http header
|
# construct the http header
|
||||||
if ($headerParams != null) {
|
if ($headerParams !== null) {
|
||||||
# add default header
|
# add default header
|
||||||
$headerParams = array_merge((array)self::$default_header, $headerParams);
|
$headerParams = array_merge((array)self::$default_header, $headerParams);
|
||||||
|
|
||||||
|
@ -187,14 +187,11 @@ class APIClient {
|
|||||||
$this->updateParamsForAuth($headerParams, $queryParams, $authSettings);
|
$this->updateParamsForAuth($headerParams, $queryParams, $authSettings);
|
||||||
|
|
||||||
# construct the http header
|
# construct the http header
|
||||||
if ($headerParams != null) {
|
$headerParams = array_merge((array)self::$default_header, (array)$headerParams);
|
||||||
# add default header
|
|
||||||
$headerParams = array_merge((array)self::$default_header, $headerParams);
|
|
||||||
|
|
||||||
foreach ($headerParams as $key => $val) {
|
foreach ($headerParams as $key => $val) {
|
||||||
$headers[] = "$key: $val";
|
$headers[] = "$key: $val";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// form data
|
// form data
|
||||||
if ($postData and in_array('Content-Type: application/x-www-form-urlencoded', $headers)) {
|
if ($postData and in_array('Content-Type: application/x-www-form-urlencoded', $headers)) {
|
||||||
@ -390,7 +387,7 @@ class APIClient {
|
|||||||
$deserialized = $values;
|
$deserialized = $values;
|
||||||
} elseif ($class == 'DateTime') {
|
} elseif ($class == 'DateTime') {
|
||||||
$deserialized = new \DateTime($data);
|
$deserialized = new \DateTime($data);
|
||||||
} elseif (in_array($class, array('string', 'int', 'float', 'double', 'bool'))) {
|
} elseif (in_array($class, array('string', 'int', 'float', 'double', 'bool', 'object'))) {
|
||||||
settype($data, $class);
|
settype($data, $class);
|
||||||
$deserialized = $data;
|
$deserialized = $data;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
//require_once('vendor/autoload.php');
|
//require_once('vendor/autoload.php');
|
||||||
require_once('SwaggerClient-php/SwaggerClient.php');
|
require_once('SwaggerClient-php/SwaggerClient.php');
|
||||||
|
|
||||||
|
$c = array_merge((array)$a, (array)$b);
|
||||||
|
|
||||||
// initialize the API client
|
// initialize the API client
|
||||||
//$api_client = new SwaggerClient\APIClient('http://petstore.swagger.io/v2');
|
//$api_client = new SwaggerClient\APIClient('http://petstore.swagger.io/v2');
|
||||||
//$api_client->addDefaultHeader("test1", "value1");
|
//$api_client->addDefaultHeader("test1", "value1");
|
||||||
@ -11,6 +13,8 @@ try {
|
|||||||
// get pet by id
|
// get pet by id
|
||||||
//$pet_api = new SwaggerClient\PetAPI($api_client);
|
//$pet_api = new SwaggerClient\PetAPI($api_client);
|
||||||
$pet_api = new SwaggerClient\PetAPI();
|
$pet_api = new SwaggerClient\PetAPI();
|
||||||
|
// test default header
|
||||||
|
$pet_api->getApiClient()->addDefaultHeader("TEST_API_KEY", "09182sdkanafndsl903");
|
||||||
// return Pet (model)
|
// return Pet (model)
|
||||||
$response = $pet_api->getPetById($petId);
|
$response = $pet_api->getPetById($petId);
|
||||||
var_dump($response);
|
var_dump($response);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user