Пример #1
0
<?php

require_once __DIR__ . '/SwaggerClient-php/autoload.php';
// show error reporting
//ini_set('display_errors', 1);
//error_reporting(~0);
// to enable logging
//Swagger\Client\Configuration::$debug = true;
//Swagger\Client\Configuration::$debug_file = '/var/tmp/php_debug.log';
// to debug report
print Swagger\Client\Configuration::toDebugReport();
// to change temp folder path
Swagger\Client\Configuration::getDefaultConfiguration()->setTempFolderPath('/var/tmp/php/');
$petId = 10005;
// ID of pet that needs to be fetched
try {
    // get pet by id
    //$api_client = new Swagger\Client\ApiClient('http://petstore.swagger.io/v2');
    //$api_client->getConfig()->addDefaultHeader("test1", "value1");
    //$pet_api = new Swagger\Client\PetAPI($api_client);
    $pet_api = new Swagger\Client\Api\PetApi();
    $pet_api->getApiClient()->getConfig()->setTempFolderPath('/var/tmp/php/');
    // test default header
    //$pet_api->getApiClient()->addDefaultHeader("TEST_API_KEY", "09182sdkanafndsl903");
    // return Pet (model)
    $response = $pet_api->getPetById($petId);
    // to test __toString()
    print $response;
    // add pet (post json)
    $new_pet_id = 10005;
    $new_pet = new Swagger\Client\Model\Pet();
Пример #2
0
<?php

require_once __DIR__ . '/SwaggerClient-php/autoload.php';
// show error reporting
//ini_set('display_errors', 1);
//error_reporting(~0);
// to debug report
print Swagger\Client\Configuration::toDebugReport();
// to change temp folder path
Swagger\Client\Configuration::getDefaultConfiguration()->setTempFolderPath('/var/tmp/php/');
// to enable logging
Swagger\Client\Configuration::getDefaultConfiguration()->setDebug(true);
Swagger\Client\Configuration::getDefaultConfiguration()->setDebugFile('/var/tmp/php_debug.log');
$petId = 10005;
// ID of pet that needs to be fetched
try {
    // get pet by id
    //$api_client = new Swagger\Client\ApiClient('http://petstore.swagger.io/v2');
    //$api_client->getConfig()->addDefaultHeader("test1", "value1");
    //$pet_api = new Swagger\Client\PetAPI($api_client);
    $pet_api = new Swagger\Client\Api\PetApi();
    $pet_api->getApiClient()->getConfig()->setTempFolderPath('/var/tmp/php/');
    // test default header
    //$pet_api->getApiClient()->addDefaultHeader("TEST_API_KEY", "09182sdkanafndsl903");
    // return Pet (model)
    $response = $pet_api->getPetById($petId);
    // to test __toString()
    print $response;
    // add pet (post json)
    $new_pet_id = 10005;
    $new_pet = new Swagger\Client\Model\Pet();