forked from loafle/openapi-generator-original
change static method to instance method, update test case to remove php warning
This commit is contained in:
parent
672fcd5a14
commit
9aca2868b9
@ -25,7 +25,7 @@ class ApiClient {
|
|||||||
public static $PUT = "PUT";
|
public static $PUT = "PUT";
|
||||||
public static $DELETE = "DELETE";
|
public static $DELETE = "DELETE";
|
||||||
|
|
||||||
private static $default_header = array();
|
private $default_header = array();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @var string timeout (second) of the HTTP request, by default set to 0, no timeout
|
* @var string timeout (second) of the HTTP request, by default set to 0, no timeout
|
||||||
@ -58,7 +58,7 @@ class ApiClient {
|
|||||||
if (!is_string($header_name))
|
if (!is_string($header_name))
|
||||||
throw new \InvalidArgumentException('Header name must be a string.');
|
throw new \InvalidArgumentException('Header name must be a string.');
|
||||||
|
|
||||||
self::$default_header[$header_name] = $header_value;
|
$this->default_header[$header_name] = $header_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,7 +67,7 @@ class ApiClient {
|
|||||||
* @return array default header
|
* @return array default header
|
||||||
*/
|
*/
|
||||||
public function getDefaultHeader() {
|
public function getDefaultHeader() {
|
||||||
return self::$default_header;
|
return $this->default_header;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,7 +76,7 @@ class ApiClient {
|
|||||||
* @param string $header_name header name (e.g. Token)
|
* @param string $header_name header name (e.g. Token)
|
||||||
*/
|
*/
|
||||||
public function deleteDefaultHeader($header_name) {
|
public function deleteDefaultHeader($header_name) {
|
||||||
unset(self::$default_header[$header_name]);
|
unset($this->default_header[$header_name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -182,7 +182,7 @@ class ApiClient {
|
|||||||
$this->updateParamsForAuth($headerParams, $queryParams, $authSettings);
|
$this->updateParamsForAuth($headerParams, $queryParams, $authSettings);
|
||||||
|
|
||||||
# construct the http header
|
# construct the http header
|
||||||
$headerParams = array_merge((array)self::$default_header, (array)$headerParams);
|
$headerParams = array_merge((array)$this->default_header, (array)$headerParams);
|
||||||
|
|
||||||
foreach ($headerParams as $key => $val) {
|
foreach ($headerParams as $key => $val) {
|
||||||
$headers[] = "$key: $val";
|
$headers[] = "$key: $val";
|
||||||
@ -307,8 +307,8 @@ class ApiClient {
|
|||||||
* @param string $value a string which will be part of the path
|
* @param string $value a string which will be part of the path
|
||||||
* @return string the serialized object
|
* @return string the serialized object
|
||||||
*/
|
*/
|
||||||
public static function toPathValue($value) {
|
public function toPathValue($value) {
|
||||||
return rawurlencode(self::toString($value));
|
return rawurlencode($this->toString($value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -319,11 +319,11 @@ class ApiClient {
|
|||||||
* @param object $object an object to be serialized to a string
|
* @param object $object an object to be serialized to a string
|
||||||
* @return string the serialized object
|
* @return string the serialized object
|
||||||
*/
|
*/
|
||||||
public static function toQueryValue($object) {
|
public function toQueryValue($object) {
|
||||||
if (is_array($object)) {
|
if (is_array($object)) {
|
||||||
return implode(',', $object);
|
return implode(',', $object);
|
||||||
} else {
|
} else {
|
||||||
return self::toString($object);
|
return $this->toString($object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,8 +334,8 @@ class ApiClient {
|
|||||||
* @param string $value a string which will be part of the header
|
* @param string $value a string which will be part of the header
|
||||||
* @return string the header string
|
* @return string the header string
|
||||||
*/
|
*/
|
||||||
public static function toHeaderValue($value) {
|
public function toHeaderValue($value) {
|
||||||
return self::toString($value);
|
return $this->toString($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -345,8 +345,8 @@ class ApiClient {
|
|||||||
* @param string $value the value of the form parameter
|
* @param string $value the value of the form parameter
|
||||||
* @return string the form string
|
* @return string the form string
|
||||||
*/
|
*/
|
||||||
public static function toFormValue($value) {
|
public function toFormValue($value) {
|
||||||
return self::toString($value);
|
return $this->toString($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -356,7 +356,7 @@ class ApiClient {
|
|||||||
* @param string $value the value of the parameter
|
* @param string $value the value of the parameter
|
||||||
* @return string the header string
|
* @return string the header string
|
||||||
*/
|
*/
|
||||||
public static function toString($value) {
|
public function toString($value) {
|
||||||
if ($value instanceof \DateTime) { // datetime in ISO8601 format
|
if ($value instanceof \DateTime) { // datetime in ISO8601 format
|
||||||
return $value->format(\DateTime::ISO8601);
|
return $value->format(\DateTime::ISO8601);
|
||||||
}
|
}
|
||||||
@ -372,7 +372,7 @@ class ApiClient {
|
|||||||
* @param string $class class name is passed as a string
|
* @param string $class class name is passed as a string
|
||||||
* @return object an instance of $class
|
* @return object an instance of $class
|
||||||
*/
|
*/
|
||||||
public static function deserialize($data, $class)
|
public function deserialize($data, $class)
|
||||||
{
|
{
|
||||||
if (null === $data) {
|
if (null === $data) {
|
||||||
$deserialized = null;
|
$deserialized = null;
|
||||||
@ -383,14 +383,14 @@ class ApiClient {
|
|||||||
$subClass_array = explode(',', $inner, 2);
|
$subClass_array = explode(',', $inner, 2);
|
||||||
$subClass = $subClass_array[1];
|
$subClass = $subClass_array[1];
|
||||||
foreach ($data as $key => $value) {
|
foreach ($data as $key => $value) {
|
||||||
$deserialized[$key] = self::deserialize($value, $subClass);
|
$deserialized[$key] = $this->deserialize($value, $subClass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif (strcasecmp(substr($class, 0, 6),'array[') == 0) {
|
} elseif (strcasecmp(substr($class, 0, 6),'array[') == 0) {
|
||||||
$subClass = substr($class, 6, -1);
|
$subClass = substr($class, 6, -1);
|
||||||
$values = array();
|
$values = array();
|
||||||
foreach ($data as $key => $value) {
|
foreach ($data as $key => $value) {
|
||||||
$values[] = self::deserialize($value, $subClass);
|
$values[] = $this->deserialize($value, $subClass);
|
||||||
}
|
}
|
||||||
$deserialized = $values;
|
$deserialized = $values;
|
||||||
} elseif ($class == 'DateTime') {
|
} elseif ($class == 'DateTime') {
|
||||||
@ -404,7 +404,7 @@ class ApiClient {
|
|||||||
foreach ($instance::$swaggerTypes as $property => $type) {
|
foreach ($instance::$swaggerTypes as $property => $type) {
|
||||||
$original_property_name = $instance::$attributeMap[$property];
|
$original_property_name = $instance::$attributeMap[$property];
|
||||||
if (isset($original_property_name) && isset($data->$original_property_name)) {
|
if (isset($original_property_name) && isset($data->$original_property_name)) {
|
||||||
$instance->$property = self::deserialize($data->$original_property_name, $type);
|
$instance->$property = $this->deserialize($data->$original_property_name, $type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$deserialized = $instance;
|
$deserialized = $instance;
|
||||||
@ -419,7 +419,7 @@ class ApiClient {
|
|||||||
* @param array[string] $accept Array of header
|
* @param array[string] $accept Array of header
|
||||||
* @return string Accept (e.g. application/json)
|
* @return string Accept (e.g. application/json)
|
||||||
*/
|
*/
|
||||||
public static function selectHeaderAccept($accept) {
|
public function selectHeaderAccept($accept) {
|
||||||
if (count($accept) === 0 or (count($accept) === 1 and $accept[0] === '')) {
|
if (count($accept) === 0 or (count($accept) === 1 and $accept[0] === '')) {
|
||||||
return NULL;
|
return NULL;
|
||||||
} elseif (preg_grep("/application\/json/i", $accept)) {
|
} elseif (preg_grep("/application\/json/i", $accept)) {
|
||||||
@ -435,7 +435,7 @@ class ApiClient {
|
|||||||
* @param array[string] content_type_array Array fo content-type
|
* @param array[string] content_type_array Array fo content-type
|
||||||
* @return string Content-Type (e.g. application/json)
|
* @return string Content-Type (e.g. application/json)
|
||||||
*/
|
*/
|
||||||
public static function selectHeaderContentType($content_type) {
|
public function selectHeaderContentType($content_type) {
|
||||||
if (count($content_type) === 0 or (count($content_type) === 1 and $content_type[0] === '')) {
|
if (count($content_type) === 0 or (count($content_type) === 1 and $content_type[0] === '')) {
|
||||||
return 'application/json';
|
return 'application/json';
|
||||||
} elseif (preg_grep("/application\/json/i", $content_type)) {
|
} elseif (preg_grep("/application\/json/i", $content_type)) {
|
||||||
|
@ -100,7 +100,7 @@ class {{classname}} {
|
|||||||
}{{/pathParams}}
|
}{{/pathParams}}
|
||||||
{{#formParams}}// form params
|
{{#formParams}}// form params
|
||||||
if (${{paramName}} !== null) {
|
if (${{paramName}} !== null) {
|
||||||
$formParams['{{baseName}}'] = {{#isFile}}'@' . {{/isFile}}$this->apiClient->toFormValue(${{paramName}});
|
$formParams['{{baseName}}'] = {{#isFile}}'@'.{{/isFile}}$this->apiClient->toFormValue(${{paramName}});
|
||||||
}{{/formParams}}
|
}{{/formParams}}
|
||||||
{{#bodyParams}}// body params
|
{{#bodyParams}}// body params
|
||||||
$_tempBody = null;
|
$_tempBody = null;
|
||||||
|
@ -25,7 +25,7 @@ class ApiClient {
|
|||||||
public static $PUT = "PUT";
|
public static $PUT = "PUT";
|
||||||
public static $DELETE = "DELETE";
|
public static $DELETE = "DELETE";
|
||||||
|
|
||||||
private static $default_header = array();
|
private $default_header = array();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @var string timeout (second) of the HTTP request, by default set to 0, no timeout
|
* @var string timeout (second) of the HTTP request, by default set to 0, no timeout
|
||||||
@ -58,7 +58,7 @@ class ApiClient {
|
|||||||
if (!is_string($header_name))
|
if (!is_string($header_name))
|
||||||
throw new \InvalidArgumentException('Header name must be a string.');
|
throw new \InvalidArgumentException('Header name must be a string.');
|
||||||
|
|
||||||
self::$default_header[$header_name] = $header_value;
|
$this->default_header[$header_name] = $header_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,7 +67,7 @@ class ApiClient {
|
|||||||
* @return array default header
|
* @return array default header
|
||||||
*/
|
*/
|
||||||
public function getDefaultHeader() {
|
public function getDefaultHeader() {
|
||||||
return self::$default_header;
|
return $this->default_header;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,7 +76,7 @@ class ApiClient {
|
|||||||
* @param string $header_name header name (e.g. Token)
|
* @param string $header_name header name (e.g. Token)
|
||||||
*/
|
*/
|
||||||
public function deleteDefaultHeader($header_name) {
|
public function deleteDefaultHeader($header_name) {
|
||||||
unset(self::$default_header[$header_name]);
|
unset($this->default_header[$header_name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -187,7 +187,7 @@ class ApiClient {
|
|||||||
$this->updateParamsForAuth($headerParams, $queryParams, $authSettings);
|
$this->updateParamsForAuth($headerParams, $queryParams, $authSettings);
|
||||||
|
|
||||||
# construct the http header
|
# construct the http header
|
||||||
$headerParams = array_merge((array)self::$default_header, (array)$headerParams);
|
$headerParams = array_merge((array)$this->default_header, (array)$headerParams);
|
||||||
|
|
||||||
foreach ($headerParams as $key => $val) {
|
foreach ($headerParams as $key => $val) {
|
||||||
$headers[] = "$key: $val";
|
$headers[] = "$key: $val";
|
||||||
@ -312,8 +312,8 @@ class ApiClient {
|
|||||||
* @param string $value a string which will be part of the path
|
* @param string $value a string which will be part of the path
|
||||||
* @return string the serialized object
|
* @return string the serialized object
|
||||||
*/
|
*/
|
||||||
public static function toPathValue($value) {
|
public function toPathValue($value) {
|
||||||
return rawurlencode(self::toString($value));
|
return rawurlencode($this->toString($value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -324,11 +324,11 @@ class ApiClient {
|
|||||||
* @param object $object an object to be serialized to a string
|
* @param object $object an object to be serialized to a string
|
||||||
* @return string the serialized object
|
* @return string the serialized object
|
||||||
*/
|
*/
|
||||||
public static function toQueryValue($object) {
|
public function toQueryValue($object) {
|
||||||
if (is_array($object)) {
|
if (is_array($object)) {
|
||||||
return implode(',', $object);
|
return implode(',', $object);
|
||||||
} else {
|
} else {
|
||||||
return self::toString($object);
|
return $this->toString($object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,8 +339,8 @@ class ApiClient {
|
|||||||
* @param string $value a string which will be part of the header
|
* @param string $value a string which will be part of the header
|
||||||
* @return string the header string
|
* @return string the header string
|
||||||
*/
|
*/
|
||||||
public static function toHeaderValue($value) {
|
public function toHeaderValue($value) {
|
||||||
return self::toString($value);
|
return $this->toString($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -350,8 +350,8 @@ class ApiClient {
|
|||||||
* @param string $value the value of the form parameter
|
* @param string $value the value of the form parameter
|
||||||
* @return string the form string
|
* @return string the form string
|
||||||
*/
|
*/
|
||||||
public static function toFormValue($value) {
|
public function toFormValue($value) {
|
||||||
return self::toString($value);
|
return $this->toString($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -361,7 +361,7 @@ class ApiClient {
|
|||||||
* @param string $value the value of the parameter
|
* @param string $value the value of the parameter
|
||||||
* @return string the header string
|
* @return string the header string
|
||||||
*/
|
*/
|
||||||
public static function toString($value) {
|
public function toString($value) {
|
||||||
if ($value instanceof \DateTime) { // datetime in ISO8601 format
|
if ($value instanceof \DateTime) { // datetime in ISO8601 format
|
||||||
return $value->format(\DateTime::ISO8601);
|
return $value->format(\DateTime::ISO8601);
|
||||||
}
|
}
|
||||||
@ -377,7 +377,7 @@ class ApiClient {
|
|||||||
* @param string $class class name is passed as a string
|
* @param string $class class name is passed as a string
|
||||||
* @return object an instance of $class
|
* @return object an instance of $class
|
||||||
*/
|
*/
|
||||||
public static function deserialize($data, $class)
|
public function deserialize($data, $class)
|
||||||
{
|
{
|
||||||
if (null === $data) {
|
if (null === $data) {
|
||||||
$deserialized = null;
|
$deserialized = null;
|
||||||
@ -388,14 +388,14 @@ class ApiClient {
|
|||||||
$subClass_array = explode(',', $inner, 2);
|
$subClass_array = explode(',', $inner, 2);
|
||||||
$subClass = $subClass_array[1];
|
$subClass = $subClass_array[1];
|
||||||
foreach ($data as $key => $value) {
|
foreach ($data as $key => $value) {
|
||||||
$deserialized[$key] = self::deserialize($value, $subClass);
|
$deserialized[$key] = $this->deserialize($value, $subClass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif (strcasecmp(substr($class, 0, 6),'array[') == 0) {
|
} elseif (strcasecmp(substr($class, 0, 6),'array[') == 0) {
|
||||||
$subClass = substr($class, 6, -1);
|
$subClass = substr($class, 6, -1);
|
||||||
$values = array();
|
$values = array();
|
||||||
foreach ($data as $key => $value) {
|
foreach ($data as $key => $value) {
|
||||||
$values[] = self::deserialize($value, $subClass);
|
$values[] = $this->deserialize($value, $subClass);
|
||||||
}
|
}
|
||||||
$deserialized = $values;
|
$deserialized = $values;
|
||||||
} elseif ($class == 'DateTime') {
|
} elseif ($class == 'DateTime') {
|
||||||
@ -409,7 +409,7 @@ class ApiClient {
|
|||||||
foreach ($instance::$swaggerTypes as $property => $type) {
|
foreach ($instance::$swaggerTypes as $property => $type) {
|
||||||
$original_property_name = $instance::$attributeMap[$property];
|
$original_property_name = $instance::$attributeMap[$property];
|
||||||
if (isset($original_property_name) && isset($data->$original_property_name)) {
|
if (isset($original_property_name) && isset($data->$original_property_name)) {
|
||||||
$instance->$property = self::deserialize($data->$original_property_name, $type);
|
$instance->$property = $this->deserialize($data->$original_property_name, $type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$deserialized = $instance;
|
$deserialized = $instance;
|
||||||
@ -424,7 +424,7 @@ class ApiClient {
|
|||||||
* @param array[string] $accept Array of header
|
* @param array[string] $accept Array of header
|
||||||
* @return string Accept (e.g. application/json)
|
* @return string Accept (e.g. application/json)
|
||||||
*/
|
*/
|
||||||
public static function selectHeaderAccept($accept) {
|
public function selectHeaderAccept($accept) {
|
||||||
if (count($accept) === 0 or (count($accept) === 1 and $accept[0] === '')) {
|
if (count($accept) === 0 or (count($accept) === 1 and $accept[0] === '')) {
|
||||||
return NULL;
|
return NULL;
|
||||||
} elseif (preg_grep("/application\/json/i", $accept)) {
|
} elseif (preg_grep("/application\/json/i", $accept)) {
|
||||||
@ -440,7 +440,7 @@ class ApiClient {
|
|||||||
* @param array[string] content_type_array Array fo content-type
|
* @param array[string] content_type_array Array fo content-type
|
||||||
* @return string Content-Type (e.g. application/json)
|
* @return string Content-Type (e.g. application/json)
|
||||||
*/
|
*/
|
||||||
public static function selectHeaderContentType($content_type) {
|
public function selectHeaderContentType($content_type) {
|
||||||
if (count($content_type) === 0 or (count($content_type) === 1 and $content_type[0] === '')) {
|
if (count($content_type) === 0 or (count($content_type) === 1 and $content_type[0] === '')) {
|
||||||
return 'application/json';
|
return 'application/json';
|
||||||
} elseif (preg_grep("/application\/json/i", $content_type)) {
|
} elseif (preg_grep("/application\/json/i", $content_type)) {
|
||||||
|
@ -327,7 +327,7 @@ class PetApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// authentication setting, if any
|
// authentication setting, if any
|
||||||
$authSettings = array('petstore_auth', 'api_key');
|
$authSettings = array('api_key', 'petstore_auth');
|
||||||
|
|
||||||
// make the API Call
|
// make the API Call
|
||||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||||
@ -516,7 +516,7 @@ class PetApi {
|
|||||||
$formParams['additionalMetadata'] = $this->apiClient->toFormValue($additional_metadata);
|
$formParams['additionalMetadata'] = $this->apiClient->toFormValue($additional_metadata);
|
||||||
}// form params
|
}// form params
|
||||||
if ($file !== null) {
|
if ($file !== null) {
|
||||||
$formParams['file'] = '@' . $this->apiClient->toFormValue($file);
|
$formParams['file'] = '@'.$this->apiClient->toFormValue($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,6 +7,9 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
// add a new pet (id 10005) to ensure the pet object is available for all the tests
|
// 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() {
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
error_reporting(~0);
|
||||||
|
|
||||||
// enable debugging
|
// enable debugging
|
||||||
//SwaggerClient\Configuration::$debug = true;
|
//SwaggerClient\Configuration::$debug = true;
|
||||||
|
|
||||||
@ -38,25 +41,26 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testApiClient()
|
public function testApiClient()
|
||||||
{
|
{
|
||||||
// test selectHeaderAccept
|
// test selectHeaderAccept
|
||||||
$this->assertSame('application/json', SwaggerClient\ApiClient::selectHeaderAccept(array('application/xml','application/json')));
|
$api_client = new SwaggerClient\ApiClient();
|
||||||
$this->assertSame(NULL, SwaggerClient\ApiClient::selectHeaderAccept(array()));
|
$this->assertSame('application/json', $api_client->selectHeaderAccept(array('application/xml','application/json')));
|
||||||
$this->assertSame('application/yaml,application/xml', SwaggerClient\ApiClient::selectHeaderAccept(array('application/yaml','application/xml')));
|
$this->assertSame(NULL, $api_client->selectHeaderAccept(array()));
|
||||||
|
$this->assertSame('application/yaml,application/xml', $api_client->selectHeaderAccept(array('application/yaml','application/xml')));
|
||||||
|
|
||||||
// test selectHeaderContentType
|
// test selectHeaderContentType
|
||||||
$this->assertSame('application/json', SwaggerClient\ApiClient::selectHeaderContentType(array('application/xml','application/json')));
|
$this->assertSame('application/json', $api_client->selectHeaderContentType(array('application/xml','application/json')));
|
||||||
$this->assertSame('application/json', SwaggerClient\ApiClient::selectHeaderContentType(array()));
|
$this->assertSame('application/json', $api_client->selectHeaderContentType(array()));
|
||||||
$this->assertSame('application/yaml,application/xml', SwaggerClient\ApiClient::selectHeaderContentType(array('application/yaml','application/xml')));
|
$this->assertSame('application/yaml,application/xml', $api_client->selectHeaderContentType(array('application/yaml','application/xml')));
|
||||||
|
|
||||||
// test addDefaultHeader and getDefaultHeader
|
// test addDefaultHeader and getDefaultHeader
|
||||||
SwaggerClient\ApiClient::addDefaultHeader('test1', 'value1');
|
$api_client->addDefaultHeader('test1', 'value1');
|
||||||
SwaggerClient\ApiClient::addDefaultHeader('test2', 200);
|
$api_client->addDefaultHeader('test2', 200);
|
||||||
$defaultHeader = SwaggerClient\ApiClient::getDefaultHeader();
|
$defaultHeader = $api_client->getDefaultHeader();
|
||||||
$this->assertSame('value1', $defaultHeader['test1']);
|
$this->assertSame('value1', $defaultHeader['test1']);
|
||||||
$this->assertSame(200, $defaultHeader['test2']);
|
$this->assertSame(200, $defaultHeader['test2']);
|
||||||
|
|
||||||
// test deleteDefaultHeader
|
// test deleteDefaultHeader
|
||||||
SwaggerClient\ApiClient::deleteDefaultHeader('test2');
|
$api_client->deleteDefaultHeader('test2');
|
||||||
$defaultHeader = SwaggerClient\ApiClient::getDefaultHeader();
|
$defaultHeader = $api_client->getDefaultHeader();
|
||||||
$this->assertFalse(isset($defaultHeader['test2']));
|
$this->assertFalse(isset($defaultHeader['test2']));
|
||||||
|
|
||||||
$pet_api = new SwaggerClient\PetAPI();
|
$pet_api = new SwaggerClient\PetAPI();
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
//require_once('vendor/autoload.php');
|
//require_once('vendor/autoload.php');
|
||||||
require_once('SwaggerClient-php/SwaggerClient.php');
|
require_once('SwaggerClient-php/SwaggerClient.php');
|
||||||
|
|
||||||
|
// show error reporting
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
error_reporting(~0);
|
||||||
|
|
||||||
// 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");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user