openapi-generator/samples/client/petstore/php/test.php

18 lines
501 B
PHP
Raw Normal View History

2015-04-06 10:03:15 +00:00
<?php
//require_once('vendor/autoload.php');
require_once('SwaggerClient-php/SwaggerClient.php');
2015-04-06 10:03:15 +00:00
// initialize the API client
$api_client = new SwaggerClient\APIClient('http://petstore.swagger.io/v2');
$petId = 10005; // ID of pet that needs to be fetched
2015-04-06 10:03:15 +00:00
try {
$pet_api = new SwaggerClient\PetAPI($api_client);
2015-04-06 10:03:15 +00:00
// return Pet (model)
$response = $pet_api->getPetById($petId);
var_dump($response);
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
?>