本文整理汇总了PHP中Swagger\Client\ApiClient::getConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiClient::getConfig方法的具体用法?PHP ApiClient::getConfig怎么用?PHP ApiClient::getConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Swagger\Client\ApiClient
的用法示例。
在下文中一共展示了ApiClient::getConfig方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ApiClient
/**
* Constructor
* @param \Swagger\Client\ApiClient|null $apiClient The api client to use
*/
function __construct($apiClient = null)
{
if ($apiClient == null) {
$apiClient = new ApiClient();
$apiClient->getConfig()->setHost('http://petstore.swagger.io/v2');
}
$this->apiClient = $apiClient;
}
示例2: __construct
/**
* Constructor
*
* @param \Swagger\Client\ApiClient|null $apiClient The api client to use
*/
public function __construct(\Swagger\Client\ApiClient $apiClient = null)
{
if ($apiClient == null) {
$apiClient = new ApiClient();
$apiClient->getConfig()->setHost('http://example.com/rest/default');
}
$this->apiClient = $apiClient;
}
示例3: testApiClient
public function testApiClient()
{
// test selectHeaderAccept
$api_client = new ApiClient();
$this->assertSame('application/json', $api_client->selectHeaderAccept(array('application/xml', 'application/json')));
$this->assertSame(null, $api_client->selectHeaderAccept(array()));
$this->assertSame('application/yaml,application/xml', $api_client->selectHeaderAccept(array('application/yaml', 'application/xml')));
// test selectHeaderContentType
$this->assertSame('application/json', $api_client->selectHeaderContentType(array('application/xml', 'application/json')));
$this->assertSame('application/json', $api_client->selectHeaderContentType(array()));
$this->assertSame('application/yaml,application/xml', $api_client->selectHeaderContentType(array('application/yaml', 'application/xml')));
// test addDefaultHeader and getDefaultHeader
$api_client->getConfig()->addDefaultHeader('test1', 'value1');
$api_client->getConfig()->addDefaultHeader('test2', 200);
$defaultHeader = $api_client->getConfig()->getDefaultHeaders();
$this->assertSame('value1', $defaultHeader['test1']);
$this->assertSame(200, $defaultHeader['test2']);
// test deleteDefaultHeader
$api_client->getConfig()->deleteDefaultHeader('test2');
$defaultHeader = $api_client->getConfig()->getDefaultHeaders();
$this->assertFalse(isset($defaultHeader['test2']));
$pet_api2 = new Api\PetApi();
$config3 = new Configuration();
$apiClient3 = new ApiClient($config3);
$apiClient3->getConfig()->setUserAgent('api client 3');
$config4 = new Configuration();
$apiClient4 = new ApiClient($config4);
$apiClient4->getConfig()->setUserAgent('api client 4');
$pet_api3 = new Api\PetApi($apiClient3);
// 2 different api clients are not the same
$this->assertNotEquals($apiClient3, $apiClient4);
// customied pet api not using the old pet api's api client
$this->assertNotEquals($pet_api2->getApiClient(), $pet_api3->getApiClient());
// test access token
$api_client->getConfig()->setAccessToken("testing_only");
$this->assertSame('testing_only', $api_client->getConfig()->getAccessToken());
}