update php sample

This commit is contained in:
wing328 2015-06-09 13:31:14 +08:00
parent d155ddd026
commit 7fd996bc86
11 changed files with 1682 additions and 1666 deletions

View File

@ -1,32 +1,32 @@
{ {
"name": "SwaggerClient/SwaggerClient-php", "name": "SwaggerClient/SwaggerClient-php",
"description": "", "description": "",
"keywords": [ "keywords": [
"swagger", "swagger",
"php", "php",
"sdk", "sdk",
"api" "api"
], ],
"homepage": "http://swagger.io", "homepage": "http://swagger.io",
"license": "Apache v2", "license": "Apache v2",
"authors": [ "authors": [
{ {
"name": "Swagger and contributors", "name": "Swagger and contributors",
"homepage": "https://github.com/swagger-api/swagger-codegen" "homepage": "https://github.com/swagger-api/swagger-codegen"
} }
], ],
"require": { "require": {
"php": ">=5.3.3", "php": ">=5.3.3",
"ext-curl": "*", "ext-curl": "*",
"ext-json": "*", "ext-json": "*",
"ext-mbstring": "*" "ext-mbstring": "*"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~4.0", "phpunit/phpunit": "~4.0",
"satooshi/php-coveralls": "~0.6.1", "satooshi/php-coveralls": "~0.6.1",
"squizlabs/php_codesniffer": "~2.0" "squizlabs/php_codesniffer": "~2.0"
}, },
"autoload": { "autoload": {
"psr-4": { "SwaggerClient\\" : "lib/" } "psr-4": { "SwaggerClient\\" : "lib/" }
} }
} }

View File

@ -43,409 +43,412 @@ class ApiClient {
function __construct($host = null) { function __construct($host = null) {
if ($host === null) { if ($host === null) {
$this->host = 'http://petstore.swagger.io/v2'; $this->host = 'http://petstore.swagger.io/v2';
} else { } else {
$this->host = $host; $this->host = $host;
} }
} }
/** /**
* add default header * add default header
* *
* @param string $header_name header name (e.g. Token) * @param string $header_name header name (e.g. Token)
* @param string $header_value header value (e.g. 1z8wp3) * @param string $header_value header value (e.g. 1z8wp3)
*/ */
public function addDefaultHeader($header_name, $header_value) { public function addDefaultHeader($header_name, $header_value) {
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; self::$default_header[$header_name] = $header_value;
} }
/** /**
* get the default header * get the default header
* *
* @return array default header * @return array default header
*/ */
public function getDefaultHeader() { public function getDefaultHeader() {
return self::$default_header; return self::$default_header;
} }
/** /**
* delete the default header based on header name * delete the default header based on header name
* *
* @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(self::$default_header[$header_name]);
} }
/** /**
* set the user agent of the api client * set the user agent of the api client
* *
* @param string $user_agent the user agent of the api client * @param string $user_agent the user agent of the api client
*/ */
public function setUserAgent($user_agent) { public function setUserAgent($user_agent) {
if (!is_string($user_agent)) if (!is_string($user_agent))
throw new \InvalidArgumentException('User-agent must be a string.'); throw new \InvalidArgumentException('User-agent must be a string.');
$this->user_agent= $user_agent; $this->user_agent= $user_agent;
} }
/** /**
* get the user agent of the api client * get the user agent of the api client
* *
* @return string user agent * @return string user agent
*/ */
public function getUserAgent($user_agent) { public function getUserAgent($user_agent) {
return $this->user_agent; return $this->user_agent;
} }
/** /**
* set the HTTP timeout value * set the HTTP timeout value
* *
* @param integer $seconds Number of seconds before timing out [set to 0 for no timeout] * @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
*/ */
public function setTimeout($seconds) { public function setTimeout($seconds) {
if (!is_numeric($seconds) || $seconds < 0) if (!is_numeric($seconds) || $seconds < 0)
throw new \InvalidArgumentException('Timeout value must be numeric and a non-negative number.'); throw new \InvalidArgumentException('Timeout value must be numeric and a non-negative number.');
$this->curl_timeout = $seconds; $this->curl_timeout = $seconds;
} }
/** /**
* get the HTTP timeout value * get the HTTP timeout value
* *
* @return string HTTP timeout value * @return string HTTP timeout value
*/ */
public function getTimeout() { public function getTimeout() {
return $this->curl_timeout; return $this->curl_timeout;
} }
/** /**
* Get API key (with prefix if set) * Get API key (with prefix if set)
* @param string key name * @param string key name
* @return string API key with the prefix * @return string API key with the prefix
*/ */
public function getApiKeyWithPrefix($apiKey) { public function getApiKeyWithPrefix($apiKey) {
if (isset(Configuration::$apiKeyPrefix[$apiKey])) { if (isset(Configuration::$apiKeyPrefix[$apiKey])) {
return Configuration::$apiKeyPrefix[$apiKey]." ".Configuration::$apiKey[$apiKey]; return Configuration::$apiKeyPrefix[$apiKey]." ".Configuration::$apiKey[$apiKey];
} else if (isset(Configuration::$apiKey[$apiKey])) { } else if (isset(Configuration::$apiKey[$apiKey])) {
return Configuration::$apiKey[$apiKey]; return Configuration::$apiKey[$apiKey];
} else { } else {
return; return;
} }
} }
/** /**
* update hearder and query param based on authentication setting * update hearder and query param based on authentication setting
* *
* @param array $headerParams header parameters (by ref) * @param array $headerParams header parameters (by ref)
* @param array $queryParams query parameters (by ref) * @param array $queryParams query parameters (by ref)
* @param array $authSettings array of authentication scheme (e.g ['api_key']) * @param array $authSettings array of authentication scheme (e.g ['api_key'])
*/ */
public function updateParamsForAuth(&$headerParams, &$queryParams, $authSettings) public function updateParamsForAuth(&$headerParams, &$queryParams, $authSettings)
{ {
if (count($authSettings) == 0) if (count($authSettings) == 0)
return; return;
// one endpoint can have more than 1 auth settings
foreach($authSettings as $auth) {
// determine which one to use
switch($auth) {
// one endpoint can have more than 1 auth settings
foreach($authSettings as $auth) {
// determine which one to use
switch($auth) {
case 'api_key': case 'api_key':
$headerParams['api_key'] = $this->getApiKeyWithPrefix('api_key'); $headerParams['api_key'] = $this->getApiKeyWithPrefix('api_key');
break; break;
case 'petstore_auth': case 'petstore_auth':
//TODO support oauth //TODO support oauth
break; break;
default:
//TODO show warning about security definition not found
}
}
}
/** default:
* @param string $resourcePath path to method endpoint //TODO show warning about security definition not found
* @param string $method method to call }
* @param array $queryParams parameters to be place in query URL }
* @param array $postData parameters to be placed in POST body }
* @param array $headerParams parameters to be place in request header
* @return mixed
*/
public function callApi($resourcePath, $method, $queryParams, $postData,
$headerParams, $authSettings) {
$headers = array(); /**
* @param string $resourcePath path to method endpoint
* @param string $method method to call
* @param array $queryParams parameters to be place in query URL
* @param array $postData parameters to be placed in POST body
* @param array $headerParams parameters to be place in request header
* @return mixed
*/
public function callApi($resourcePath, $method, $queryParams, $postData,
$headerParams, $authSettings) {
# determine authentication setting $headers = array();
$this->updateParamsForAuth($headerParams, $queryParams, $authSettings);
# construct the http header # determine authentication setting
$headerParams = array_merge((array)self::$default_header, (array)$headerParams); $this->updateParamsForAuth($headerParams, $queryParams, $authSettings);
foreach ($headerParams as $key => $val) { # construct the http header
$headers[] = "$key: $val"; $headerParams = array_merge((array)self::$default_header, (array)$headerParams);
}
// form data foreach ($headerParams as $key => $val) {
if ($postData and in_array('Content-Type: application/x-www-form-urlencoded', $headers)) { $headers[] = "$key: $val";
$postData = http_build_query($postData); }
}
else if ((is_object($postData) or is_array($postData)) and !in_array('Content-Type: multipart/form-data', $headers)) { // json model
$postData = json_encode($this->sanitizeForSerialization($postData));
}
$url = $this->host . $resourcePath; // form data
if ($postData and in_array('Content-Type: application/x-www-form-urlencoded', $headers)) {
$postData = http_build_query($postData);
}
else if ((is_object($postData) or is_array($postData)) and !in_array('Content-Type: multipart/form-data', $headers)) { // json model
$postData = json_encode($this->sanitizeForSerialization($postData));
}
$curl = curl_init(); $url = $this->host . $resourcePath;
// set timeout, if needed
if ($this->curl_timeout != 0) {
curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timeout);
}
// return the result on success, rather than just TRUE
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); $curl = curl_init();
// set timeout, if needed
if ($this->curl_timeout != 0) {
curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timeout);
}
// return the result on success, rather than just TRUE
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
if (! empty($queryParams)) { curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$url = ($url . '?' . http_build_query($queryParams));
}
if ($method == self::$POST) { if (! empty($queryParams)) {
curl_setopt($curl, CURLOPT_POST, true); $url = ($url . '?' . http_build_query($queryParams));
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); }
} else if ($method == self::$PATCH) {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH");
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
} else if ($method == self::$PUT) {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
} else if ($method == self::$DELETE) {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
} else if ($method != self::$GET) {
throw new ApiException('Method ' . $method . ' is not recognized.');
}
curl_setopt($curl, CURLOPT_URL, $url);
// Set user agent if ($method == self::$POST) {
curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent); curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
} else if ($method == self::$PATCH) {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH");
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
} else if ($method == self::$PUT) {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
} else if ($method == self::$DELETE) {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
} else if ($method != self::$GET) {
throw new ApiException('Method ' . $method . ' is not recognized.');
}
curl_setopt($curl, CURLOPT_URL, $url);
// debugging for curl // Set user agent
if (Configuration::$debug) { curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
error_log("[DEBUG] HTTP Request body ~BEGIN~\n".print_r($postData, true)."\n~END~\n", 3, Configuration::$debug_file);
curl_setopt($curl, CURLOPT_VERBOSE, 1); // debugging for curl
curl_setopt($curl, CURLOPT_STDERR, fopen(Configuration::$debug_file, 'a')); if (Configuration::$debug) {
} else { error_log("[DEBUG] HTTP Request body ~BEGIN~\n".print_r($postData, true)."\n~END~\n", 3, Configuration::$debug_file);
curl_setopt($curl, CURLOPT_VERBOSE, 0);
}
// obtain the HTTP response headers curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_HEADER, 1); curl_setopt($curl, CURLOPT_STDERR, fopen(Configuration::$debug_file, 'a'));
} else {
curl_setopt($curl, CURLOPT_VERBOSE, 0);
}
// Make the request // obtain the HTTP response headers
$response = curl_exec($curl); curl_setopt($curl, CURLOPT_HEADER, 1);
$http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$http_header = substr($response, 0, $http_header_size);
$http_body = substr($response, $http_header_size);
$response_info = curl_getinfo($curl);
// debug HTTP response body // Make the request
if (Configuration::$debug) { $response = curl_exec($curl);
error_log("[DEBUG] HTTP Response body ~BEGIN~\n".print_r($http_body, true)."\n~END~\n", 3, Configuration::$debug_file); $http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
} $http_header = substr($response, 0, $http_header_size);
$http_body = substr($response, $http_header_size);
$response_info = curl_getinfo($curl);
// Handle the response // debug HTTP response body
if ($response_info['http_code'] == 0) { if (Configuration::$debug) {
throw new ApiException("API call to $url timed out: ".serialize($response_info), 0, null, null); error_log("[DEBUG] HTTP Response body ~BEGIN~\n".print_r($http_body, true)."\n~END~\n", 3, Configuration::$debug_file);
} else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) { }
$data = json_decode($http_body);
if (json_last_error() > 0) { // if response is a string
$data = $http_body;
}
} else {
throw new ApiException("[".$response_info['http_code']."] Error connecting to the API ($url)",
$response_info['http_code'], $http_header, $http_body);
}
return $data;
}
/** // Handle the response
* Build a JSON POST object if ($response_info['http_code'] == 0) {
*/ throw new ApiException("API call to $url timed out: ".serialize($response_info), 0, null, null);
protected function sanitizeForSerialization($data) } else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
{ $data = json_decode($http_body);
if (is_scalar($data) || null === $data) { if (json_last_error() > 0) { // if response is a string
$sanitized = $data; $data = $http_body;
} else if ($data instanceof \DateTime) { }
$sanitized = $data->format(\DateTime::ISO8601); } else {
} else if (is_array($data)) { throw new ApiException("[".$response_info['http_code']."] Error connecting to the API ($url)",
foreach ($data as $property => $value) { $response_info['http_code'], $http_header, $http_body);
$data[$property] = $this->sanitizeForSerialization($value); }
} return $data;
$sanitized = $data; }
} else if (is_object($data)) {
$values = array();
foreach (array_keys($data::$swaggerTypes) as $property) {
if ($data->$property !== null) {
$values[$data::$attributeMap[$property]] = $this->sanitizeForSerialization($data->$property);
}
}
$sanitized = $values;
} else {
$sanitized = (string)$data;
}
return $sanitized; /**
} * Build a JSON POST object
*/
protected function sanitizeForSerialization($data)
{
if (is_scalar($data) || null === $data) {
$sanitized = $data;
} else if ($data instanceof \DateTime) {
$sanitized = $data->format(\DateTime::ISO8601);
} else if (is_array($data)) {
foreach ($data as $property => $value) {
$data[$property] = $this->sanitizeForSerialization($value);
}
$sanitized = $data;
} else if (is_object($data)) {
$values = array();
foreach (array_keys($data::$swaggerTypes) as $property) {
if ($data->$property !== null) {
$values[$data::$attributeMap[$property]] = $this->sanitizeForSerialization($data->$property);
}
}
$sanitized = $values;
} else {
$sanitized = (string)$data;
}
/** return $sanitized;
* Take value and turn it into a string suitable for inclusion in }
* the path, by url-encoding.
* @param string $value a string which will be part of the path
* @return string the serialized object
*/
public static function toPathValue($value) {
return rawurlencode(self::toString($value));
}
/** /**
* Take value and turn it into a string suitable for inclusion in * Take value and turn it into a string suitable for inclusion in
* the query, by imploding comma-separated if it's an object. * the path, by url-encoding.
* If it's a string, pass through unchanged. It will be url-encoded * @param string $value a string which will be part of the path
* later. * @return string the serialized object
* @param object $object an object to be serialized to a string */
* @return string the serialized object public static function toPathValue($value) {
*/ return rawurlencode(self::toString($value));
public static function toQueryValue($object) { }
if (is_array($object)) {
return implode(',', $object);
} else {
return self::toString($object);
}
}
/** /**
* Take value and turn it into a string suitable for inclusion in * Take value and turn it into a string suitable for inclusion in
* the header. If it's a string, pass through unchanged * the query, by imploding comma-separated if it's an object.
* If it's a datetime object, format it in ISO8601 * If it's a string, pass through unchanged. It will be url-encoded
* @param string $value a string which will be part of the header * later.
* @return string the header string * @param object $object an object to be serialized to a string
*/ * @return string the serialized object
public static function toHeaderValue($value) { */
return self::toString($value); public static function toQueryValue($object) {
} if (is_array($object)) {
return implode(',', $object);
} else {
return self::toString($object);
}
}
/** /**
* Take value and turn it into a string suitable for inclusion in * Take value and turn it into a string suitable for inclusion in
* the http body (form parameter). If it's a string, pass through unchanged * the header. If it's a string, pass through unchanged
* If it's a datetime object, format it in ISO8601 * If it's a datetime object, format it in ISO8601
* @param string $value the value of the form parameter * @param string $value a string which will be part of the header
* @return string the form string * @return string the header string
*/ */
public static function toFormValue($value) { public static function toHeaderValue($value) {
return self::toString($value); return self::toString($value);
} }
/** /**
* Take value and turn it into a string suitable for inclusion in * Take value and turn it into a string suitable for inclusion in
* the parameter. If it's a string, pass through unchanged * the http body (form parameter). If it's a string, pass through unchanged
* If it's a datetime object, format it in ISO8601 * If it's a datetime object, format it in ISO8601
* @param string $value the value of the parameter * @param string $value the value of the form parameter
* @return string the header string * @return string the form string
*/ */
public static function toString($value) { public static function toFormValue($value) {
if ($value instanceof \DateTime) { // datetime in ISO8601 format return self::toString($value);
return $value->format(\DateTime::ISO8601); }
}
else {
return $value;
}
}
/** /**
* Deserialize a JSON string into an object * Take value and turn it into a string suitable for inclusion in
* * the parameter. If it's a string, pass through unchanged
* @param object $object object or primitive to be deserialized * If it's a datetime object, format it in ISO8601
* @param string $class class name is passed as a string * @param string $value the value of the parameter
* @return object an instance of $class * @return string the header string
*/ */
public static function deserialize($data, $class) public static function toString($value) {
{ if ($value instanceof \DateTime) { // datetime in ISO8601 format
if (null === $data) { return $value->format(\DateTime::ISO8601);
$deserialized = null; }
} elseif (substr($class, 0, 4) == 'map[') { # for associative array e.g. map[string,int] else {
$inner = substr($class, 4, -1); return $value;
$deserialized = array(); }
if(strrpos($inner, ",") !== false) { }
$subClass_array = explode(',', $inner, 2);
$subClass = $subClass_array[1];
foreach ($data as $key => $value) {
$deserialized[$key] = self::deserialize($value, $subClass);
}
}
} elseif (strcasecmp(substr($class, 0, 6),'array[') == 0) {
$subClass = substr($class, 6, -1);
$values = array();
foreach ($data as $key => $value) {
$values[] = self::deserialize($value, $subClass);
}
$deserialized = $values;
} elseif ($class == 'DateTime') {
$deserialized = new \DateTime($data);
} elseif (in_array($class, array('string', 'int', 'float', 'double', 'bool', 'object'))) {
settype($data, $class);
$deserialized = $data;
} else {
$class = "SwaggerClient\\models\\".$class;
$instance = new $class();
foreach ($instance::$swaggerTypes as $property => $type) {
$original_property_name = $instance::$attributeMap[$property];
if (isset($original_property_name) && isset($data->$original_property_name)) {
$instance->$property = self::deserialize($data->$original_property_name, $type);
}
}
$deserialized = $instance;
}
return $deserialized; /**
} * Deserialize a JSON string into an object
*
* @param object $object object or primitive to be deserialized
* @param string $class class name is passed as a string
* @return object an instance of $class
*/
public static function deserialize($data, $class)
{
if (null === $data) {
$deserialized = null;
} elseif (substr($class, 0, 4) == 'map[') { # for associative array e.g. map[string,int]
$inner = substr($class, 4, -1);
$deserialized = array();
if(strrpos($inner, ",") !== false) {
$subClass_array = explode(',', $inner, 2);
$subClass = $subClass_array[1];
foreach ($data as $key => $value) {
$deserialized[$key] = self::deserialize($value, $subClass);
}
}
} elseif (strcasecmp(substr($class, 0, 6),'array[') == 0) {
$subClass = substr($class, 6, -1);
$values = array();
foreach ($data as $key => $value) {
$values[] = self::deserialize($value, $subClass);
}
$deserialized = $values;
} elseif ($class == 'DateTime') {
$deserialized = new \DateTime($data);
} elseif (in_array($class, array('string', 'int', 'float', 'double', 'bool', 'object'))) {
settype($data, $class);
$deserialized = $data;
} else {
$class = "SwaggerClient\\models\\".$class;
$instance = new $class();
foreach ($instance::$swaggerTypes as $property => $type) {
$original_property_name = $instance::$attributeMap[$property];
if (isset($original_property_name) && isset($data->$original_property_name)) {
$instance->$property = self::deserialize($data->$original_property_name, $type);
}
}
$deserialized = $instance;
}
/* return $deserialized;
* return the header 'Accept' based on an array of Accept provided }
*
* @param array[string] $accept Array of header
* @return string Accept (e.g. application/json)
*/
public static function selectHeaderAccept($accept) {
if (count($accept) === 0 or (count($accept) === 1 and $accept[0] === '')) {
return NULL;
} elseif (preg_grep("/application\/json/i", $accept)) {
return 'application/json';
} else {
return implode(',', $accept);
}
}
/* /*
* return the content type based on an array of content-type provided * return the header 'Accept' based on an array of Accept provided
* *
* @param array[string] content_type_array Array fo content-type * @param array[string] $accept Array of header
* @return string Content-Type (e.g. application/json) * @return string Accept (e.g. application/json)
*/ */
public static function selectHeaderContentType($content_type) { public static function selectHeaderAccept($accept) {
if (count($content_type) === 0 or (count($content_type) === 1 and $content_type[0] === '')) { if (count($accept) === 0 or (count($accept) === 1 and $accept[0] === '')) {
return 'application/json'; return NULL;
} elseif (preg_grep("/application\/json/i", $content_type)) { } elseif (preg_grep("/application\/json/i", $accept)) {
return 'application/json'; return 'application/json';
} else { } else {
return implode(',', $content_type); return implode(',', $accept);
} }
} }
/*
* return the content type based on an array of content-type provided
*
* @param array[string] content_type_array Array fo content-type
* @return string Content-Type (e.g. application/json)
*/
public static function selectHeaderContentType($content_type) {
if (count($content_type) === 0 or (count($content_type) === 1 and $content_type[0] === '')) {
return 'application/json';
} elseif (preg_grep("/application\/json/i", $content_type)) {
return 'application/json';
} else {
return implode(',', $content_type);
}
}
} }

View File

@ -34,25 +34,25 @@ class ApiException extends Exception {
public function __construct($message="", $code=0, $responseHeaders=null, $responseBody=null) { public function __construct($message="", $code=0, $responseHeaders=null, $responseBody=null) {
parent::__construct($message, $code); parent::__construct($message, $code);
$this->response_headers = $responseHeaders; $this->response_headers = $responseHeaders;
$this->response_body = $responseBody; $this->response_body = $responseBody;
} }
/** /**
* Get the HTTP response header * Get the HTTP response header
* *
* @return string HTTP response header * @return string HTTP response header
*/ */
public function getResponseHeaders() { public function getResponseHeaders() {
return $this->response_headers; return $this->response_headers;
} }
/** /**
* Get the HTTP response body * Get the HTTP response body
* *
* @return string HTTP response body * @return string HTTP response body
*/ */
public function getResponseBody() { public function getResponseBody() {
return $this->response_body; return $this->response_body;
} }
} }

View File

@ -29,29 +29,30 @@ class PetApi {
if (Configuration::$apiClient === null) { if (Configuration::$apiClient === null) {
Configuration::$apiClient = new ApiClient(); // create a new API client if not present Configuration::$apiClient = new ApiClient(); // create a new API client if not present
$this->apiClient = Configuration::$apiClient; $this->apiClient = Configuration::$apiClient;
} }
else else
$this->apiClient = Configuration::$apiClient; // use the default one $this->apiClient = Configuration::$apiClient; // use the default one
} else { } else {
$this->apiClient = $apiClient; // use the one provided by the user $this->apiClient = $apiClient; // use the one provided by the user
} }
} }
private $apiClient; // instance of the ApiClient private $apiClient; // instance of the ApiClient
/** /**
* get the API client * get the API client
*/ */
public function getApiClient() { public function getApiClient() {
return $this->apiClient; return $this->apiClient;
} }
/**
* set the API client
*/
public function setApiClient($apiClient) {
$this->apiClient = $apiClient;
}
/**
* set the API client
*/
public function setApiClient($apiClient) {
$this->apiClient = $apiClient;
}
/** /**
* updatePet * updatePet
@ -106,6 +107,7 @@ $this->apiClient = $apiClient;
} }
/** /**
* addPet * addPet
* *
@ -159,6 +161,7 @@ $this->apiClient = $apiClient;
} }
/** /**
* findPetsByStatus * findPetsByStatus
* *
@ -216,6 +219,7 @@ $this->apiClient = $apiClient;
$responseObject = $this->apiClient->deserialize($response,'array[Pet]'); $responseObject = $this->apiClient->deserialize($response,'array[Pet]');
return $responseObject; return $responseObject;
} }
/** /**
* findPetsByTags * findPetsByTags
* *
@ -273,6 +277,7 @@ $this->apiClient = $apiClient;
$responseObject = $this->apiClient->deserialize($response,'array[Pet]'); $responseObject = $this->apiClient->deserialize($response,'array[Pet]');
return $responseObject; return $responseObject;
} }
/** /**
* getPetById * getPetById
* *
@ -336,6 +341,7 @@ $this->apiClient = $apiClient;
$responseObject = $this->apiClient->deserialize($response,'Pet'); $responseObject = $this->apiClient->deserialize($response,'Pet');
return $responseObject; return $responseObject;
} }
/** /**
* updatePetWithForm * updatePetWithForm
* *
@ -402,6 +408,7 @@ $this->apiClient = $apiClient;
} }
/** /**
* deletePet * deletePet
* *
@ -464,6 +471,7 @@ $this->apiClient = $apiClient;
} }
/** /**
* uploadFile * uploadFile
* *
@ -531,4 +539,5 @@ $this->apiClient = $apiClient;
} }
} }

View File

@ -29,29 +29,30 @@ class StoreApi {
if (Configuration::$apiClient === null) { if (Configuration::$apiClient === null) {
Configuration::$apiClient = new ApiClient(); // create a new API client if not present Configuration::$apiClient = new ApiClient(); // create a new API client if not present
$this->apiClient = Configuration::$apiClient; $this->apiClient = Configuration::$apiClient;
} }
else else
$this->apiClient = Configuration::$apiClient; // use the default one $this->apiClient = Configuration::$apiClient; // use the default one
} else { } else {
$this->apiClient = $apiClient; // use the one provided by the user $this->apiClient = $apiClient; // use the one provided by the user
} }
} }
private $apiClient; // instance of the ApiClient private $apiClient; // instance of the ApiClient
/** /**
* get the API client * get the API client
*/ */
public function getApiClient() { public function getApiClient() {
return $this->apiClient; return $this->apiClient;
} }
/**
* set the API client
*/
public function setApiClient($apiClient) {
$this->apiClient = $apiClient;
}
/**
* set the API client
*/
public function setApiClient($apiClient) {
$this->apiClient = $apiClient;
}
/** /**
* getInventory * getInventory
@ -106,6 +107,7 @@ $this->apiClient = $apiClient;
$responseObject = $this->apiClient->deserialize($response,'map[string,int]'); $responseObject = $this->apiClient->deserialize($response,'map[string,int]');
return $responseObject; return $responseObject;
} }
/** /**
* placeOrder * placeOrder
* *
@ -164,6 +166,7 @@ $this->apiClient = $apiClient;
$responseObject = $this->apiClient->deserialize($response,'Order'); $responseObject = $this->apiClient->deserialize($response,'Order');
return $responseObject; return $responseObject;
} }
/** /**
* getOrderById * getOrderById
* *
@ -227,6 +230,7 @@ $this->apiClient = $apiClient;
$responseObject = $this->apiClient->deserialize($response,'Order'); $responseObject = $this->apiClient->deserialize($response,'Order');
return $responseObject; return $responseObject;
} }
/** /**
* deleteOrder * deleteOrder
* *
@ -286,4 +290,5 @@ $this->apiClient = $apiClient;
} }
} }

View File

@ -29,29 +29,30 @@ class UserApi {
if (Configuration::$apiClient === null) { if (Configuration::$apiClient === null) {
Configuration::$apiClient = new ApiClient(); // create a new API client if not present Configuration::$apiClient = new ApiClient(); // create a new API client if not present
$this->apiClient = Configuration::$apiClient; $this->apiClient = Configuration::$apiClient;
} }
else else
$this->apiClient = Configuration::$apiClient; // use the default one $this->apiClient = Configuration::$apiClient; // use the default one
} else { } else {
$this->apiClient = $apiClient; // use the one provided by the user $this->apiClient = $apiClient; // use the one provided by the user
} }
} }
private $apiClient; // instance of the ApiClient private $apiClient; // instance of the ApiClient
/** /**
* get the API client * get the API client
*/ */
public function getApiClient() { public function getApiClient() {
return $this->apiClient; return $this->apiClient;
} }
/**
* set the API client
*/
public function setApiClient($apiClient) {
$this->apiClient = $apiClient;
}
/**
* set the API client
*/
public function setApiClient($apiClient) {
$this->apiClient = $apiClient;
}
/** /**
* createUser * createUser
@ -106,6 +107,7 @@ $this->apiClient = $apiClient;
} }
/** /**
* createUsersWithArrayInput * createUsersWithArrayInput
* *
@ -159,6 +161,7 @@ $this->apiClient = $apiClient;
} }
/** /**
* createUsersWithListInput * createUsersWithListInput
* *
@ -212,6 +215,7 @@ $this->apiClient = $apiClient;
} }
/** /**
* loginUser * loginUser
* *
@ -273,6 +277,7 @@ $this->apiClient = $apiClient;
$responseObject = $this->apiClient->deserialize($response,'string'); $responseObject = $this->apiClient->deserialize($response,'string');
return $responseObject; return $responseObject;
} }
/** /**
* logoutUser * logoutUser
* *
@ -321,6 +326,7 @@ $this->apiClient = $apiClient;
} }
/** /**
* getUserByName * getUserByName
* *
@ -384,6 +390,7 @@ $this->apiClient = $apiClient;
$responseObject = $this->apiClient->deserialize($response,'User'); $responseObject = $this->apiClient->deserialize($response,'User');
return $responseObject; return $responseObject;
} }
/** /**
* updateUser * updateUser
* *
@ -447,6 +454,7 @@ $this->apiClient = $apiClient;
} }
/** /**
* deleteUser * deleteUser
* *
@ -506,4 +514,5 @@ $this->apiClient = $apiClient;
} }
} }

View File

@ -15,7 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
/** /**
* *
* *
@ -62,5 +61,4 @@ class Category implements ArrayAccess {
public function offsetUnset($offset) { public function offsetUnset($offset) {
unset($this->$offset); unset($this->$offset);
} }
} }

View File

@ -15,7 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
/** /**
* *
* *
@ -81,5 +80,4 @@ class Order implements ArrayAccess {
public function offsetUnset($offset) { public function offsetUnset($offset) {
unset($this->$offset); unset($this->$offset);
} }
} }

View File

@ -15,7 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
/** /**
* *
* *
@ -81,5 +80,4 @@ class Pet implements ArrayAccess {
public function offsetUnset($offset) { public function offsetUnset($offset) {
unset($this->$offset); unset($this->$offset);
} }
} }

View File

@ -15,7 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
/** /**
* *
* *
@ -62,5 +61,4 @@ class Tag implements ArrayAccess {
public function offsetUnset($offset) { public function offsetUnset($offset) {
unset($this->$offset); unset($this->$offset);
} }
} }

View File

@ -15,7 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
/** /**
* *
* *
@ -89,5 +88,4 @@ class User implements ArrayAccess {
public function offsetUnset($offset) { public function offsetUnset($offset) {
unset($this->$offset); unset($this->$offset);
} }
} }