diff --git a/samples/client/petstore/php/SwaggerClient-php/composer.json b/samples/client/petstore/php/SwaggerClient-php/composer.json index a097d929c62..13fc1b62690 100644 --- a/samples/client/petstore/php/SwaggerClient-php/composer.json +++ b/samples/client/petstore/php/SwaggerClient-php/composer.json @@ -1,32 +1,32 @@ { -"name": "SwaggerClient/SwaggerClient-php", -"description": "", -"keywords": [ -"swagger", -"php", -"sdk", -"api" -], -"homepage": "http://swagger.io", -"license": "Apache v2", -"authors": [ -{ -"name": "Swagger and contributors", -"homepage": "https://github.com/swagger-api/swagger-codegen" -} -], -"require": { -"php": ">=5.3.3", -"ext-curl": "*", -"ext-json": "*", -"ext-mbstring": "*" -}, -"require-dev": { -"phpunit/phpunit": "~4.0", -"satooshi/php-coveralls": "~0.6.1", -"squizlabs/php_codesniffer": "~2.0" -}, -"autoload": { -"psr-4": { "SwaggerClient\\" : "lib/" } -} + "name": "SwaggerClient/SwaggerClient-php", + "description": "", + "keywords": [ + "swagger", + "php", + "sdk", + "api" + ], + "homepage": "http://swagger.io", + "license": "Apache v2", + "authors": [ + { + "name": "Swagger and contributors", + "homepage": "https://github.com/swagger-api/swagger-codegen" + } + ], + "require": { + "php": ">=5.3.3", + "ext-curl": "*", + "ext-json": "*", + "ext-mbstring": "*" + }, + "require-dev": { + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "~0.6.1", + "squizlabs/php_codesniffer": "~2.0" + }, + "autoload": { + "psr-4": { "SwaggerClient\\" : "lib/" } + } } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/APIClient.php b/samples/client/petstore/php/SwaggerClient-php/lib/APIClient.php index dd4c3c1f1b1..b8357f9b479 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/APIClient.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/APIClient.php @@ -43,409 +43,412 @@ class ApiClient { function __construct($host = null) { if ($host === null) { $this->host = 'http://petstore.swagger.io/v2'; -} else { -$this->host = $host; -} -} + } else { + $this->host = $host; + } + } -/** -* add default header -* -* @param string $header_name header name (e.g. Token) -* @param string $header_value header value (e.g. 1z8wp3) -*/ -public function addDefaultHeader($header_name, $header_value) { -if (!is_string($header_name)) -throw new \InvalidArgumentException('Header name must be a string.'); + /** + * add default header + * + * @param string $header_name header name (e.g. Token) + * @param string $header_value header value (e.g. 1z8wp3) + */ + public function addDefaultHeader($header_name, $header_value) { + if (!is_string($header_name)) + 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 -* -* @return array default header -*/ -public function getDefaultHeader() { -return self::$default_header; -} + /** + * get the default header + * + * @return array default header + */ + public function getDefaultHeader() { + return self::$default_header; + } -/** -* delete the default header based on header name -* -* @param string $header_name header name (e.g. Token) -*/ -public function deleteDefaultHeader($header_name) { -unset(self::$default_header[$header_name]); -} + /** + * delete the default header based on header name + * + * @param string $header_name header name (e.g. Token) + */ + public function deleteDefaultHeader($header_name) { + unset(self::$default_header[$header_name]); + } -/** -* set the user agent of the api client -* -* @param string $user_agent the user agent of the api client -*/ -public function setUserAgent($user_agent) { -if (!is_string($user_agent)) -throw new \InvalidArgumentException('User-agent must be a string.'); + /** + * set the user agent of the api client + * + * @param string $user_agent the user agent of the api client + */ + public function setUserAgent($user_agent) { + if (!is_string($user_agent)) + 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 -* -* @return string user agent -*/ -public function getUserAgent($user_agent) { -return $this->user_agent; -} + /** + * get the user agent of the api client + * + * @return string user agent + */ + public function getUserAgent($user_agent) { + return $this->user_agent; + } -/** -* set the HTTP timeout value -* -* @param integer $seconds Number of seconds before timing out [set to 0 for no timeout] -*/ -public function setTimeout($seconds) { -if (!is_numeric($seconds) || $seconds < 0) -throw new \InvalidArgumentException('Timeout value must be numeric and a non-negative number.'); + /** + * set the HTTP timeout value + * + * @param integer $seconds Number of seconds before timing out [set to 0 for no timeout] + */ + public function setTimeout($seconds) { + if (!is_numeric($seconds) || $seconds < 0) + 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 -* -* @return string HTTP timeout value -*/ -public function getTimeout() { -return $this->curl_timeout; -} + /** + * get the HTTP timeout value + * + * @return string HTTP timeout value + */ + public function getTimeout() { + return $this->curl_timeout; + } -/** -* Get API key (with prefix if set) -* @param string key name -* @return string API key with the prefix -*/ -public function getApiKeyWithPrefix($apiKey) { -if (isset(Configuration::$apiKeyPrefix[$apiKey])) { -return Configuration::$apiKeyPrefix[$apiKey]." ".Configuration::$apiKey[$apiKey]; -} else if (isset(Configuration::$apiKey[$apiKey])) { -return Configuration::$apiKey[$apiKey]; -} else { -return; -} -} + /** + * Get API key (with prefix if set) + * @param string key name + * @return string API key with the prefix + */ + public function getApiKeyWithPrefix($apiKey) { + if (isset(Configuration::$apiKeyPrefix[$apiKey])) { + return Configuration::$apiKeyPrefix[$apiKey]." ".Configuration::$apiKey[$apiKey]; + } else if (isset(Configuration::$apiKey[$apiKey])) { + return Configuration::$apiKey[$apiKey]; + } else { + return; + } + } -/** -* update hearder and query param based on authentication setting -* -* @param array $headerParams header parameters (by ref) -* @param array $queryParams query parameters (by ref) -* @param array $authSettings array of authentication scheme (e.g ['api_key']) -*/ -public function updateParamsForAuth(&$headerParams, &$queryParams, $authSettings) -{ -if (count($authSettings) == 0) -return; + /** + * update hearder and query param based on authentication setting + * + * @param array $headerParams header parameters (by ref) + * @param array $queryParams query parameters (by ref) + * @param array $authSettings array of authentication scheme (e.g ['api_key']) + */ + public function updateParamsForAuth(&$headerParams, &$queryParams, $authSettings) + { + if (count($authSettings) == 0) + return; -// one endpoint can have more than 1 auth settings -foreach($authSettings as $auth) { -// determine which one to use -switch($auth) { - case 'api_key': - $headerParams['api_key'] = $this->getApiKeyWithPrefix('api_key'); - - break; - case 'petstore_auth': - - //TODO support oauth - break; -default: -//TODO show warning about security definition not found -} -} -} + // one endpoint can have more than 1 auth settings + foreach($authSettings as $auth) { + // determine which one to use + switch($auth) { + + case 'api_key': + $headerParams['api_key'] = $this->getApiKeyWithPrefix('api_key'); + + break; + + case 'petstore_auth': + + //TODO support oauth + break; + + default: + //TODO show warning about security definition not found + } + } + } + + /** + * @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) { -/** -* @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) { + $headers = array(); -$headers = array(); + # determine authentication setting + $this->updateParamsForAuth($headerParams, $queryParams, $authSettings); -# determine authentication setting -$this->updateParamsForAuth($headerParams, $queryParams, $authSettings); + # construct the http header + $headerParams = array_merge((array)self::$default_header, (array)$headerParams); -# construct the http header -$headerParams = array_merge((array)self::$default_header, (array)$headerParams); + foreach ($headerParams as $key => $val) { + $headers[] = "$key: $val"; + } -foreach ($headerParams as $key => $val) { -$headers[] = "$key: $val"; -} + // 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)); + } -// 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)); -} + $url = $this->host . $resourcePath; -$url = $this->host . $resourcePath; + $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); -$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); + curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); -curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); + if (! empty($queryParams)) { + $url = ($url . '?' . http_build_query($queryParams)); + } -if (! empty($queryParams)) { -$url = ($url . '?' . http_build_query($queryParams)); -} + if ($method == self::$POST) { + 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); -if ($method == self::$POST) { -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); + // Set user agent + curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent); -// Set user agent -curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent); + // debugging for curl + if (Configuration::$debug) { + error_log("[DEBUG] HTTP Request body ~BEGIN~\n".print_r($postData, true)."\n~END~\n", 3, Configuration::$debug_file); -// debugging for curl -if (Configuration::$debug) { -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); + curl_setopt($curl, CURLOPT_STDERR, fopen(Configuration::$debug_file, 'a')); + } else { + curl_setopt($curl, CURLOPT_VERBOSE, 0); + } -curl_setopt($curl, CURLOPT_VERBOSE, 1); -curl_setopt($curl, CURLOPT_STDERR, fopen(Configuration::$debug_file, 'a')); -} else { -curl_setopt($curl, CURLOPT_VERBOSE, 0); -} + // obtain the HTTP response headers + curl_setopt($curl, CURLOPT_HEADER, 1); -// obtain the HTTP response headers -curl_setopt($curl, CURLOPT_HEADER, 1); + // Make the request + $response = curl_exec($curl); + $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); -// Make the request -$response = curl_exec($curl); -$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 + if (Configuration::$debug) { + error_log("[DEBUG] HTTP Response body ~BEGIN~\n".print_r($http_body, true)."\n~END~\n", 3, Configuration::$debug_file); + } -// debug HTTP response body -if (Configuration::$debug) { -error_log("[DEBUG] HTTP Response body ~BEGIN~\n".print_r($http_body, true)."\n~END~\n", 3, Configuration::$debug_file); -} + // Handle the response + if ($response_info['http_code'] == 0) { + throw new ApiException("API call to $url timed out: ".serialize($response_info), 0, null, null); + } 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 -if ($response_info['http_code'] == 0) { -throw new ApiException("API call to $url timed out: ".serialize($response_info), 0, null, null); -} 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; -} + /** + * 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; + } -/** -* 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; + } -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 -* 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 + * the query, by imploding comma-separated if it's an object. + * If it's a string, pass through unchanged. It will be url-encoded + * later. + * @param object $object an object to be serialized to a string + * @return string the serialized object + */ + 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 -* the query, by imploding comma-separated if it's an object. -* If it's a string, pass through unchanged. It will be url-encoded -* later. -* @param object $object an object to be serialized to a string -* @return string the serialized object -*/ -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 + * the header. If it's a string, pass through unchanged + * If it's a datetime object, format it in ISO8601 + * @param string $value a string which will be part of the header + * @return string the header string + */ + public static function toHeaderValue($value) { + return self::toString($value); + } -/** -* Take value and turn it into a string suitable for inclusion in -* the header. If it's a string, pass through unchanged -* If it's a datetime object, format it in ISO8601 -* @param string $value a string which will be part of the header -* @return string the header string -*/ -public static function toHeaderValue($value) { -return self::toString($value); -} + /** + * 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 + * If it's a datetime object, format it in ISO8601 + * @param string $value the value of the form parameter + * @return string the form string + */ + public static function toFormValue($value) { + return self::toString($value); + } -/** -* 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 -* If it's a datetime object, format it in ISO8601 -* @param string $value the value of the form parameter -* @return string the form string -*/ -public static function toFormValue($value) { -return self::toString($value); -} + /** + * Take value and turn it into a string suitable for inclusion in + * the parameter. If it's a string, pass through unchanged + * If it's a datetime object, format it in ISO8601 + * @param string $value the value of the parameter + * @return string the header string + */ + public static function toString($value) { + if ($value instanceof \DateTime) { // datetime in ISO8601 format + return $value->format(\DateTime::ISO8601); + } + else { + return $value; + } + } -/** -* Take value and turn it into a string suitable for inclusion in -* the parameter. If it's a string, pass through unchanged -* If it's a datetime object, format it in ISO8601 -* @param string $value the value of the parameter -* @return string the header string -*/ -public static function toString($value) { -if ($value instanceof \DateTime) { // datetime in ISO8601 format -return $value->format(\DateTime::ISO8601); -} -else { -return $value; -} -} + /** + * 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; + } -/** -* 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 $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 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 -* -* @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); -} -} + /* + * 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); + } + } } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ApiException.php b/samples/client/petstore/php/SwaggerClient-php/lib/ApiException.php index f11b319a4ce..51f2c4b877e 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ApiException.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ApiException.php @@ -34,25 +34,25 @@ class ApiException extends Exception { public function __construct($message="", $code=0, $responseHeaders=null, $responseBody=null) { parent::__construct($message, $code); $this->response_headers = $responseHeaders; -$this->response_body = $responseBody; -} + $this->response_body = $responseBody; + } -/** -* Get the HTTP response header -* -* @return string HTTP response header -*/ -public function getResponseHeaders() { -return $this->response_headers; -} + /** + * Get the HTTP response header + * + * @return string HTTP response header + */ + public function getResponseHeaders() { + return $this->response_headers; + } -/** -* Get the HTTP response body -* -* @return string HTTP response body -*/ -public function getResponseBody() { -return $this->response_body; -} + /** + * Get the HTTP response body + * + * @return string HTTP response body + */ + public function getResponseBody() { + return $this->response_body; + } } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/PetApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/PetApi.php index f1bec027d3d..a022430b9cd 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/PetApi.php @@ -29,506 +29,515 @@ class PetApi { if (Configuration::$apiClient === null) { Configuration::$apiClient = new ApiClient(); // create a new API client if not present $this->apiClient = Configuration::$apiClient; -} -else -$this->apiClient = Configuration::$apiClient; // use the default one -} else { -$this->apiClient = $apiClient; // use the one provided by the user -} -} - -private $apiClient; // instance of the ApiClient - -/** -* get the API client -*/ -public function getApiClient() { -return $this->apiClient; -} - -/** -* set the API client -*/ -public function setApiClient($apiClient) { -$this->apiClient = $apiClient; -} - - /** - * updatePet - * - * Update an existing pet - * - * @param Pet $body Pet object that needs to be added to the store (required) - * @return void - */ - public function updatePet($body) { - - - // parse inputs - $resourcePath = "/pet"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "PUT"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; + } + else + $this->apiClient = Configuration::$apiClient; // use the default one + } else { + $this->apiClient = $apiClient; // use the one provided by the user } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/json','application/xml')); + } - - - - - // body params - $_tempBody = null; - if (isset($body)) { - $_tempBody = $body; - } + private $apiClient; // instance of the ApiClient - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + /** + * get the API client + */ + public function getApiClient() { + return $this->apiClient; + } - // authentication setting, if any - $authSettings = array('petstore_auth'); + /** + * set the API client + */ + public function setApiClient($apiClient) { + $this->apiClient = $apiClient; + } - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + + /** + * updatePet + * + * Update an existing pet + * + * @param Pet $body Pet object that needs to be added to the store (required) + * @return void + */ + public function updatePet($body) { + - - } - /** - * addPet - * - * Add a new pet to the store - * - * @param Pet $body Pet object that needs to be added to the store (required) - * @return void - */ - public function addPet($body) { - + // parse inputs + $resourcePath = "/pet"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "PUT"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/json','application/xml')); - // parse inputs - $resourcePath = "/pet"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "POST"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/json','application/xml')); + + + + + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } - - - - - // body params - $_tempBody = null; - if (isset($body)) { - $_tempBody = $body; - } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // authentication setting, if any + $authSettings = array('petstore_auth'); - // authentication setting, if any - $authSettings = array('petstore_auth'); + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + + } + + /** + * addPet + * + * Add a new pet to the store + * + * @param Pet $body Pet object that needs to be added to the store (required) + * @return void + */ + public function addPet($body) { + - - } - /** - * findPetsByStatus - * - * Finds Pets by status - * - * @param array[string] $status Status values that need to be considered for filter (required) - * @return array[Pet] - */ - public function findPetsByStatus($status) { - + // parse inputs + $resourcePath = "/pet"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "POST"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/json','application/xml')); - // parse inputs - $resourcePath = "/pet/findByStatus"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "GET"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + + + + + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } - // query params - if($status !== null) { - $queryParams['status'] = $this->apiClient->toQueryValue($status); - } - - - - + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // authentication setting, if any + $authSettings = array('petstore_auth'); - // authentication setting, if any - $authSettings = array('petstore_auth'); + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + + } + + /** + * findPetsByStatus + * + * Finds Pets by status + * + * @param array[string] $status Status values that need to be considered for filter (required) + * @return array[Pet] + */ + public function findPetsByStatus($status) { + - if(! $response) { - return null; - } + // parse inputs + $resourcePath = "/pet/findByStatus"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "GET"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - $responseObject = $this->apiClient->deserialize($response,'array[Pet]'); - return $responseObject; - } - /** - * findPetsByTags - * - * Finds Pets by tags - * - * @param array[string] $tags Tags to filter by (required) - * @return array[Pet] - */ - public function findPetsByTags($tags) { - + // query params + if($status !== null) { + $queryParams['status'] = $this->apiClient->toQueryValue($status); + } + + + + - // parse inputs - $resourcePath = "/pet/findByTags"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "GET"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // query params - if($tags !== null) { - $queryParams['tags'] = $this->apiClient->toQueryValue($tags); - } - - - - + // authentication setting, if any + $authSettings = array('petstore_auth'); - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - // authentication setting, if any - $authSettings = array('petstore_auth'); + if(! $response) { + return null; + } - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + $responseObject = $this->apiClient->deserialize($response,'array[Pet]'); + return $responseObject; + } + + /** + * findPetsByTags + * + * Finds Pets by tags + * + * @param array[string] $tags Tags to filter by (required) + * @return array[Pet] + */ + public function findPetsByTags($tags) { + - if(! $response) { - return null; - } + // parse inputs + $resourcePath = "/pet/findByTags"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "GET"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - $responseObject = $this->apiClient->deserialize($response,'array[Pet]'); - return $responseObject; - } - /** - * getPetById - * - * Find pet by ID - * - * @param int $pet_id ID of pet that needs to be fetched (required) - * @return Pet - */ - public function getPetById($pet_id) { - - // verify the required parameter 'pet_id' is set - if ($pet_id === null) { + // query params + if($tags !== null) { + $queryParams['tags'] = $this->apiClient->toQueryValue($tags); + } + + + + + + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } + + // authentication setting, if any + $authSettings = array('petstore_auth'); + + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); + + if(! $response) { + return null; + } + + $responseObject = $this->apiClient->deserialize($response,'array[Pet]'); + return $responseObject; + } + + /** + * getPetById + * + * Find pet by ID + * + * @param int $pet_id ID of pet that needs to be fetched (required) + * @return Pet + */ + public function getPetById($pet_id) { + + // verify the required parameter 'pet_id' is set + if ($pet_id === null) { throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling getPetById'); - } - + } + - // parse inputs - $resourcePath = "/pet/{petId}"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "GET"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + // parse inputs + $resourcePath = "/pet/{petId}"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "GET"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - - - // path params - if($pet_id !== null) { - $resourcePath = str_replace("{" . "petId" . "}", - $this->apiClient->toPathValue($pet_id), $resourcePath); - } - - + + + // path params + if($pet_id !== null) { + $resourcePath = str_replace("{" . "petId" . "}", + $this->apiClient->toPathValue($pet_id), $resourcePath); + } + + - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // authentication setting, if any - $authSettings = array('api_key', 'petstore_auth'); + // authentication setting, if any + $authSettings = array('api_key', 'petstore_auth'); - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - if(! $response) { - return null; - } + if(! $response) { + return null; + } - $responseObject = $this->apiClient->deserialize($response,'Pet'); - return $responseObject; - } - /** - * updatePetWithForm - * - * Updates a pet in the store with form data - * - * @param string $pet_id ID of pet that needs to be updated (required) - * @param string $name Updated name of the pet (required) - * @param string $status Updated status of the pet (required) - * @return void - */ - public function updatePetWithForm($pet_id, $name, $status) { - - // verify the required parameter 'pet_id' is set - if ($pet_id === null) { + $responseObject = $this->apiClient->deserialize($response,'Pet'); + return $responseObject; + } + + /** + * updatePetWithForm + * + * Updates a pet in the store with form data + * + * @param string $pet_id ID of pet that needs to be updated (required) + * @param string $name Updated name of the pet (required) + * @param string $status Updated status of the pet (required) + * @return void + */ + public function updatePetWithForm($pet_id, $name, $status) { + + // verify the required parameter 'pet_id' is set + if ($pet_id === null) { throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling updatePetWithForm'); - } - + } + - // parse inputs - $resourcePath = "/pet/{petId}"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "POST"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/x-www-form-urlencoded')); + // parse inputs + $resourcePath = "/pet/{petId}"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "POST"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/x-www-form-urlencoded')); - - - // path params - if($pet_id !== null) { - $resourcePath = str_replace("{" . "petId" . "}", - $this->apiClient->toPathValue($pet_id), $resourcePath); - } - // form params - if ($name !== null) { - $formParams['name'] = $this->apiClient->toFormValue($name); - }// form params - if ($status !== null) { - $formParams['status'] = $this->apiClient->toFormValue($status); - } - + + + // path params + if($pet_id !== null) { + $resourcePath = str_replace("{" . "petId" . "}", + $this->apiClient->toPathValue($pet_id), $resourcePath); + } + // form params + if ($name !== null) { + $formParams['name'] = $this->apiClient->toFormValue($name); + }// form params + if ($status !== null) { + $formParams['status'] = $this->apiClient->toFormValue($status); + } + - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // authentication setting, if any - $authSettings = array('petstore_auth'); + // authentication setting, if any + $authSettings = array('petstore_auth'); - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - - } - /** - * deletePet - * - * Deletes a pet - * - * @param string $api_key (required) - * @param int $pet_id Pet id to delete (required) - * @return void - */ - public function deletePet($api_key, $pet_id) { - - // verify the required parameter 'pet_id' is set - if ($pet_id === null) { + + } + + /** + * deletePet + * + * Deletes a pet + * + * @param string $api_key (required) + * @param int $pet_id Pet id to delete (required) + * @return void + */ + public function deletePet($api_key, $pet_id) { + + // verify the required parameter 'pet_id' is set + if ($pet_id === null) { throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling deletePet'); - } - + } + - // parse inputs - $resourcePath = "/pet/{petId}"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "DELETE"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + // parse inputs + $resourcePath = "/pet/{petId}"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "DELETE"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - - // header params - if($api_key !== null) { - $headerParams['api_key'] = $this->apiClient->toHeaderValue($api_key); - } - // path params - if($pet_id !== null) { - $resourcePath = str_replace("{" . "petId" . "}", - $this->apiClient->toPathValue($pet_id), $resourcePath); - } - - + + // header params + if($api_key !== null) { + $headerParams['api_key'] = $this->apiClient->toHeaderValue($api_key); + } + // path params + if($pet_id !== null) { + $resourcePath = str_replace("{" . "petId" . "}", + $this->apiClient->toPathValue($pet_id), $resourcePath); + } + + - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // authentication setting, if any - $authSettings = array('petstore_auth'); + // authentication setting, if any + $authSettings = array('petstore_auth'); - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - - } - /** - * uploadFile - * - * uploads an image - * - * @param int $pet_id ID of pet to update (required) - * @param string $additional_metadata Additional data to pass to server (required) - * @param string $file file to upload (required) - * @return void - */ - public function uploadFile($pet_id, $additional_metadata, $file) { - - // verify the required parameter 'pet_id' is set - if ($pet_id === null) { + + } + + /** + * uploadFile + * + * uploads an image + * + * @param int $pet_id ID of pet to update (required) + * @param string $additional_metadata Additional data to pass to server (required) + * @param string $file file to upload (required) + * @return void + */ + public function uploadFile($pet_id, $additional_metadata, $file) { + + // verify the required parameter 'pet_id' is set + if ($pet_id === null) { throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling uploadFile'); - } - + } + - // parse inputs - $resourcePath = "/pet/{petId}/uploadImage"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "POST"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('multipart/form-data')); + // parse inputs + $resourcePath = "/pet/{petId}/uploadImage"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "POST"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('multipart/form-data')); - - - // path params - if($pet_id !== null) { - $resourcePath = str_replace("{" . "petId" . "}", - $this->apiClient->toPathValue($pet_id), $resourcePath); - } - // form params - if ($additional_metadata !== null) { - $formParams['additionalMetadata'] = $this->apiClient->toFormValue($additional_metadata); - }// form params - if ($file !== null) { - $formParams['file'] = '@' . $this->apiClient->toFormValue($file); - } - + + + // path params + if($pet_id !== null) { + $resourcePath = str_replace("{" . "petId" . "}", + $this->apiClient->toPathValue($pet_id), $resourcePath); + } + // form params + if ($additional_metadata !== null) { + $formParams['additionalMetadata'] = $this->apiClient->toFormValue($additional_metadata); + }// form params + if ($file !== null) { + $formParams['file'] = '@' . $this->apiClient->toFormValue($file); + } + - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // authentication setting, if any - $authSettings = array('petstore_auth'); + // authentication setting, if any + $authSettings = array('petstore_auth'); - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - - } + + } + } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/StoreApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/StoreApi.php index c4a5dd98127..87937a60283 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/StoreApi.php @@ -29,261 +29,266 @@ class StoreApi { if (Configuration::$apiClient === null) { Configuration::$apiClient = new ApiClient(); // create a new API client if not present $this->apiClient = Configuration::$apiClient; -} -else -$this->apiClient = Configuration::$apiClient; // use the default one -} else { -$this->apiClient = $apiClient; // use the one provided by the user -} -} - -private $apiClient; // instance of the ApiClient - -/** -* get the API client -*/ -public function getApiClient() { -return $this->apiClient; -} - -/** -* set the API client -*/ -public function setApiClient($apiClient) { -$this->apiClient = $apiClient; -} - - /** - * getInventory - * - * Returns pet inventories by status - * - * @return map[string,int] - */ - public function getInventory() { - - - // parse inputs - $resourcePath = "/store/inventory"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "GET"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; + } + else + $this->apiClient = Configuration::$apiClient; // use the default one + } else { + $this->apiClient = $apiClient; // use the one provided by the user } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + } - - - - - + private $apiClient; // instance of the ApiClient - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + /** + * get the API client + */ + public function getApiClient() { + return $this->apiClient; + } - // authentication setting, if any - $authSettings = array('api_key'); + /** + * set the API client + */ + public function setApiClient($apiClient) { + $this->apiClient = $apiClient; + } - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + + /** + * getInventory + * + * Returns pet inventories by status + * + * @return map[string,int] + */ + public function getInventory() { + - if(! $response) { - return null; - } + // parse inputs + $resourcePath = "/store/inventory"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "GET"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - $responseObject = $this->apiClient->deserialize($response,'map[string,int]'); - return $responseObject; - } - /** - * placeOrder - * - * Place an order for a pet - * - * @param Order $body order placed for purchasing the pet (required) - * @return Order - */ - public function placeOrder($body) { - + + + + + - // parse inputs - $resourcePath = "/store/order"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "POST"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - - - - - // body params - $_tempBody = null; - if (isset($body)) { - $_tempBody = $body; - } + // authentication setting, if any + $authSettings = array('api_key'); - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - // authentication setting, if any - $authSettings = array(); + if(! $response) { + return null; + } - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + $responseObject = $this->apiClient->deserialize($response,'map[string,int]'); + return $responseObject; + } + + /** + * placeOrder + * + * Place an order for a pet + * + * @param Order $body order placed for purchasing the pet (required) + * @return Order + */ + public function placeOrder($body) { + - if(! $response) { - return null; - } + // parse inputs + $resourcePath = "/store/order"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "POST"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - $responseObject = $this->apiClient->deserialize($response,'Order'); - return $responseObject; - } - /** - * getOrderById - * - * Find purchase order by ID - * - * @param string $order_id ID of pet that needs to be fetched (required) - * @return Order - */ - public function getOrderById($order_id) { - - // verify the required parameter 'order_id' is set - if ($order_id === null) { + + + + + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } + + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } + + // authentication setting, if any + $authSettings = array(); + + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); + + if(! $response) { + return null; + } + + $responseObject = $this->apiClient->deserialize($response,'Order'); + return $responseObject; + } + + /** + * getOrderById + * + * Find purchase order by ID + * + * @param string $order_id ID of pet that needs to be fetched (required) + * @return Order + */ + public function getOrderById($order_id) { + + // verify the required parameter 'order_id' is set + if ($order_id === null) { throw new \InvalidArgumentException('Missing the required parameter $order_id when calling getOrderById'); - } - + } + - // parse inputs - $resourcePath = "/store/order/{orderId}"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "GET"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + // parse inputs + $resourcePath = "/store/order/{orderId}"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "GET"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - - - // path params - if($order_id !== null) { - $resourcePath = str_replace("{" . "orderId" . "}", - $this->apiClient->toPathValue($order_id), $resourcePath); - } - - + + + // path params + if($order_id !== null) { + $resourcePath = str_replace("{" . "orderId" . "}", + $this->apiClient->toPathValue($order_id), $resourcePath); + } + + - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // authentication setting, if any - $authSettings = array(); + // authentication setting, if any + $authSettings = array(); - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - if(! $response) { - return null; - } + if(! $response) { + return null; + } - $responseObject = $this->apiClient->deserialize($response,'Order'); - return $responseObject; - } - /** - * deleteOrder - * - * Delete purchase order by ID - * - * @param string $order_id ID of the order that needs to be deleted (required) - * @return void - */ - public function deleteOrder($order_id) { - - // verify the required parameter 'order_id' is set - if ($order_id === null) { + $responseObject = $this->apiClient->deserialize($response,'Order'); + return $responseObject; + } + + /** + * deleteOrder + * + * Delete purchase order by ID + * + * @param string $order_id ID of the order that needs to be deleted (required) + * @return void + */ + public function deleteOrder($order_id) { + + // verify the required parameter 'order_id' is set + if ($order_id === null) { throw new \InvalidArgumentException('Missing the required parameter $order_id when calling deleteOrder'); - } - + } + - // parse inputs - $resourcePath = "/store/order/{orderId}"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "DELETE"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + // parse inputs + $resourcePath = "/store/order/{orderId}"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "DELETE"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - - - // path params - if($order_id !== null) { - $resourcePath = str_replace("{" . "orderId" . "}", - $this->apiClient->toPathValue($order_id), $resourcePath); - } - - + + + // path params + if($order_id !== null) { + $resourcePath = str_replace("{" . "orderId" . "}", + $this->apiClient->toPathValue($order_id), $resourcePath); + } + + - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // authentication setting, if any - $authSettings = array(); + // authentication setting, if any + $authSettings = array(); - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - - } + + } + } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/UserApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/UserApi.php index 7063d11353f..2e16022f25a 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/UserApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/UserApi.php @@ -29,481 +29,490 @@ class UserApi { if (Configuration::$apiClient === null) { Configuration::$apiClient = new ApiClient(); // create a new API client if not present $this->apiClient = Configuration::$apiClient; -} -else -$this->apiClient = Configuration::$apiClient; // use the default one -} else { -$this->apiClient = $apiClient; // use the one provided by the user -} -} - -private $apiClient; // instance of the ApiClient - -/** -* get the API client -*/ -public function getApiClient() { -return $this->apiClient; -} - -/** -* set the API client -*/ -public function setApiClient($apiClient) { -$this->apiClient = $apiClient; -} - - /** - * createUser - * - * Create user - * - * @param User $body Created user object (required) - * @return void - */ - public function createUser($body) { - - - // parse inputs - $resourcePath = "/user"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "POST"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; + } + else + $this->apiClient = Configuration::$apiClient; // use the default one + } else { + $this->apiClient = $apiClient; // use the one provided by the user } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + } - - - - - // body params - $_tempBody = null; - if (isset($body)) { - $_tempBody = $body; - } + private $apiClient; // instance of the ApiClient - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + /** + * get the API client + */ + public function getApiClient() { + return $this->apiClient; + } - // authentication setting, if any - $authSettings = array(); + /** + * set the API client + */ + public function setApiClient($apiClient) { + $this->apiClient = $apiClient; + } - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + + /** + * createUser + * + * Create user + * + * @param User $body Created user object (required) + * @return void + */ + public function createUser($body) { + - - } - /** - * createUsersWithArrayInput - * - * Creates list of users with given input array - * - * @param array[User] $body List of user object (required) - * @return void - */ - public function createUsersWithArrayInput($body) { - + // parse inputs + $resourcePath = "/user"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "POST"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - // parse inputs - $resourcePath = "/user/createWithArray"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "POST"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + + + + + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } - - - - - // body params - $_tempBody = null; - if (isset($body)) { - $_tempBody = $body; - } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // authentication setting, if any + $authSettings = array(); - // authentication setting, if any - $authSettings = array(); + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + + } + + /** + * createUsersWithArrayInput + * + * Creates list of users with given input array + * + * @param array[User] $body List of user object (required) + * @return void + */ + public function createUsersWithArrayInput($body) { + - - } - /** - * createUsersWithListInput - * - * Creates list of users with given input array - * - * @param array[User] $body List of user object (required) - * @return void - */ - public function createUsersWithListInput($body) { - + // parse inputs + $resourcePath = "/user/createWithArray"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "POST"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - // parse inputs - $resourcePath = "/user/createWithList"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "POST"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + + + + + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } - - - - - // body params - $_tempBody = null; - if (isset($body)) { - $_tempBody = $body; - } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // authentication setting, if any + $authSettings = array(); - // authentication setting, if any - $authSettings = array(); + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + + } + + /** + * createUsersWithListInput + * + * Creates list of users with given input array + * + * @param array[User] $body List of user object (required) + * @return void + */ + public function createUsersWithListInput($body) { + - - } - /** - * loginUser - * - * Logs user into the system - * - * @param string $username The user name for login (required) - * @param string $password The password for login in clear text (required) - * @return string - */ - public function loginUser($username, $password) { - + // parse inputs + $resourcePath = "/user/createWithList"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "POST"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - // parse inputs - $resourcePath = "/user/login"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "GET"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + + + + + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } - // query params - if($username !== null) { - $queryParams['username'] = $this->apiClient->toQueryValue($username); - }// query params - if($password !== null) { - $queryParams['password'] = $this->apiClient->toQueryValue($password); - } - - - - + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // authentication setting, if any + $authSettings = array(); - // authentication setting, if any - $authSettings = array(); + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + + } + + /** + * loginUser + * + * Logs user into the system + * + * @param string $username The user name for login (required) + * @param string $password The password for login in clear text (required) + * @return string + */ + public function loginUser($username, $password) { + - if(! $response) { - return null; - } + // parse inputs + $resourcePath = "/user/login"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "GET"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - $responseObject = $this->apiClient->deserialize($response,'string'); - return $responseObject; - } - /** - * logoutUser - * - * Logs out current logged in user session - * - * @return void - */ - public function logoutUser() { - + // query params + if($username !== null) { + $queryParams['username'] = $this->apiClient->toQueryValue($username); + }// query params + if($password !== null) { + $queryParams['password'] = $this->apiClient->toQueryValue($password); + } + + + + - // parse inputs - $resourcePath = "/user/logout"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "GET"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - - - - - + // authentication setting, if any + $authSettings = array(); - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - // authentication setting, if any - $authSettings = array(); + if(! $response) { + return null; + } - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + $responseObject = $this->apiClient->deserialize($response,'string'); + return $responseObject; + } + + /** + * logoutUser + * + * Logs out current logged in user session + * + * @return void + */ + public function logoutUser() { + - - } - /** - * getUserByName - * - * Get user by user name - * - * @param string $username The name that needs to be fetched. Use user1 for testing. (required) - * @return User - */ - public function getUserByName($username) { - - // verify the required parameter 'username' is set - if ($username === null) { + // parse inputs + $resourcePath = "/user/logout"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "GET"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + + + + + + + + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } + + // authentication setting, if any + $authSettings = array(); + + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); + + + } + + /** + * getUserByName + * + * Get user by user name + * + * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * @return User + */ + public function getUserByName($username) { + + // verify the required parameter 'username' is set + if ($username === null) { throw new \InvalidArgumentException('Missing the required parameter $username when calling getUserByName'); - } - + } + - // parse inputs - $resourcePath = "/user/{username}"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "GET"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + // parse inputs + $resourcePath = "/user/{username}"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "GET"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - - - // path params - if($username !== null) { - $resourcePath = str_replace("{" . "username" . "}", - $this->apiClient->toPathValue($username), $resourcePath); - } - - + + + // path params + if($username !== null) { + $resourcePath = str_replace("{" . "username" . "}", + $this->apiClient->toPathValue($username), $resourcePath); + } + + - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // authentication setting, if any - $authSettings = array(); + // authentication setting, if any + $authSettings = array(); - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - if(! $response) { - return null; - } + if(! $response) { + return null; + } - $responseObject = $this->apiClient->deserialize($response,'User'); - return $responseObject; - } - /** - * updateUser - * - * Updated user - * - * @param string $username name that need to be deleted (required) - * @param User $body Updated user object (required) - * @return void - */ - public function updateUser($username, $body) { - - // verify the required parameter 'username' is set - if ($username === null) { + $responseObject = $this->apiClient->deserialize($response,'User'); + return $responseObject; + } + + /** + * updateUser + * + * Updated user + * + * @param string $username name that need to be deleted (required) + * @param User $body Updated user object (required) + * @return void + */ + public function updateUser($username, $body) { + + // verify the required parameter 'username' is set + if ($username === null) { throw new \InvalidArgumentException('Missing the required parameter $username when calling updateUser'); - } - + } + - // parse inputs - $resourcePath = "/user/{username}"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "PUT"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + // parse inputs + $resourcePath = "/user/{username}"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "PUT"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - - - // path params - if($username !== null) { - $resourcePath = str_replace("{" . "username" . "}", - $this->apiClient->toPathValue($username), $resourcePath); - } - - // body params - $_tempBody = null; - if (isset($body)) { - $_tempBody = $body; - } + + + // path params + if($username !== null) { + $resourcePath = str_replace("{" . "username" . "}", + $this->apiClient->toPathValue($username), $resourcePath); + } + + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // authentication setting, if any - $authSettings = array(); + // authentication setting, if any + $authSettings = array(); - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - - } - /** - * deleteUser - * - * Delete user - * - * @param string $username The name that needs to be deleted (required) - * @return void - */ - public function deleteUser($username) { - - // verify the required parameter 'username' is set - if ($username === null) { + + } + + /** + * deleteUser + * + * Delete user + * + * @param string $username The name that needs to be deleted (required) + * @return void + */ + public function deleteUser($username) { + + // verify the required parameter 'username' is set + if ($username === null) { throw new \InvalidArgumentException('Missing the required parameter $username when calling deleteUser'); - } - + } + - // parse inputs - $resourcePath = "/user/{username}"; - $resourcePath = str_replace("{format}", "json", $resourcePath); - $method = "DELETE"; - $httpBody = ''; - $queryParams = array(); - $headerParams = array(); - $formParams = array(); - $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); - if (!is_null($_header_accept)) { - $headerParams['Accept'] = $_header_accept; - } - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); + // parse inputs + $resourcePath = "/user/{username}"; + $resourcePath = str_replace("{format}", "json", $resourcePath); + $method = "DELETE"; + $httpBody = ''; + $queryParams = array(); + $headerParams = array(); + $formParams = array(); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); + if (!is_null($_header_accept)) { + $headerParams['Accept'] = $_header_accept; + } + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); - - - // path params - if($username !== null) { - $resourcePath = str_replace("{" . "username" . "}", - $this->apiClient->toPathValue($username), $resourcePath); - } - - + + + // path params + if($username !== null) { + $resourcePath = str_replace("{" . "username" . "}", + $this->apiClient->toPathValue($username), $resourcePath); + } + + - // for model (json/xml) - if (isset($_tempBody)) { - $httpBody = $_tempBody; // $_tempBody is the method argument, if present - } else if (count($formParams) > 0) { - // for HTTP post (form) - $httpBody = $formParams; - } + // for model (json/xml) + if (isset($_tempBody)) { + $httpBody = $_tempBody; // $_tempBody is the method argument, if present + } else if (count($formParams) > 0) { + // for HTTP post (form) + $httpBody = $formParams; + } - // authentication setting, if any - $authSettings = array(); + // authentication setting, if any + $authSettings = array(); - // make the API Call - $response = $this->apiClient->callAPI($resourcePath, $method, - $queryParams, $httpBody, - $headerParams, $authSettings); + // make the API Call + $response = $this->apiClient->callAPI($resourcePath, $method, + $queryParams, $httpBody, + $headerParams, $authSettings); - - } + + } + } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/models/Category.php b/samples/client/petstore/php/SwaggerClient-php/lib/models/Category.php index bd7d6e9a8d0..7512921b898 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/models/Category.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/models/Category.php @@ -15,7 +15,6 @@ * limitations under the License. */ - /** * * @@ -30,37 +29,36 @@ use \ArrayAccess; class Category implements ArrayAccess { static $swaggerTypes = array( 'id' => 'int', - 'name' => 'string' - ); + 'name' => 'string' + ); - static $attributeMap = array( - 'id' => 'id', - 'name' => 'name' - ); + static $attributeMap = array( + 'id' => 'id', + 'name' => 'name' + ); - - public $id; /* int */ - public $name; /* string */ + + public $id; /* int */ + public $name; /* string */ - public function __construct(array $data = null) { + public function __construct(array $data = null) { $this->id = $data["id"]; $this->name = $data["name"]; - } + } - public function offsetExists($offset) { + public function offsetExists($offset) { return isset($this->$offset); - } + } - public function offsetGet($offset) { + public function offsetGet($offset) { return $this->$offset; - } + } - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value) { $this->$offset = $value; - } + } - public function offsetUnset($offset) { + public function offsetUnset($offset) { unset($this->$offset); - } - } - + } +} diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/models/Order.php b/samples/client/petstore/php/SwaggerClient-php/lib/models/Order.php index 8f25f8da3c5..4314d0df6f3 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/models/Order.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/models/Order.php @@ -15,7 +15,6 @@ * limitations under the License. */ - /** * * @@ -30,56 +29,55 @@ use \ArrayAccess; class Order implements ArrayAccess { static $swaggerTypes = array( 'id' => 'int', - 'pet_id' => 'int', - 'quantity' => 'int', - 'ship_date' => 'DateTime', - 'status' => 'string', - 'complete' => 'boolean' - ); + 'pet_id' => 'int', + 'quantity' => 'int', + 'ship_date' => 'DateTime', + 'status' => 'string', + 'complete' => 'boolean' + ); - static $attributeMap = array( - 'id' => 'id', - 'pet_id' => 'petId', - 'quantity' => 'quantity', - 'ship_date' => 'shipDate', - 'status' => 'status', - 'complete' => 'complete' - ); + static $attributeMap = array( + 'id' => 'id', + 'pet_id' => 'petId', + 'quantity' => 'quantity', + 'ship_date' => 'shipDate', + 'status' => 'status', + 'complete' => 'complete' + ); - - public $id; /* int */ - public $pet_id; /* int */ - public $quantity; /* int */ - public $ship_date; /* DateTime */ - /** - * Order Status - */ - public $status; /* string */ - public $complete; /* boolean */ + + public $id; /* int */ + public $pet_id; /* int */ + public $quantity; /* int */ + public $ship_date; /* DateTime */ + /** + * Order Status + */ + public $status; /* string */ + public $complete; /* boolean */ - public function __construct(array $data = null) { + public function __construct(array $data = null) { $this->id = $data["id"]; $this->pet_id = $data["pet_id"]; $this->quantity = $data["quantity"]; $this->ship_date = $data["ship_date"]; $this->status = $data["status"]; $this->complete = $data["complete"]; - } + } - public function offsetExists($offset) { + public function offsetExists($offset) { return isset($this->$offset); - } + } - public function offsetGet($offset) { + public function offsetGet($offset) { return $this->$offset; - } + } - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value) { $this->$offset = $value; - } + } - public function offsetUnset($offset) { + public function offsetUnset($offset) { unset($this->$offset); - } - } - + } +} diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/models/Pet.php b/samples/client/petstore/php/SwaggerClient-php/lib/models/Pet.php index 918b39b9adf..f74c9a88315 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/models/Pet.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/models/Pet.php @@ -15,7 +15,6 @@ * limitations under the License. */ - /** * * @@ -30,56 +29,55 @@ use \ArrayAccess; class Pet implements ArrayAccess { static $swaggerTypes = array( 'id' => 'int', - 'category' => 'Category', - 'name' => 'string', - 'photo_urls' => 'array[string]', - 'tags' => 'array[Tag]', - 'status' => 'string' - ); + 'category' => 'Category', + 'name' => 'string', + 'photo_urls' => 'array[string]', + 'tags' => 'array[Tag]', + 'status' => 'string' + ); - static $attributeMap = array( - 'id' => 'id', - 'category' => 'category', - 'name' => 'name', - 'photo_urls' => 'photoUrls', - 'tags' => 'tags', - 'status' => 'status' - ); + static $attributeMap = array( + 'id' => 'id', + 'category' => 'category', + 'name' => 'name', + 'photo_urls' => 'photoUrls', + 'tags' => 'tags', + 'status' => 'status' + ); - - public $id; /* int */ - public $category; /* Category */ - public $name; /* string */ - public $photo_urls; /* array[string] */ - public $tags; /* array[Tag] */ - /** - * pet status in the store - */ - public $status; /* string */ + + public $id; /* int */ + public $category; /* Category */ + public $name; /* string */ + public $photo_urls; /* array[string] */ + public $tags; /* array[Tag] */ + /** + * pet status in the store + */ + public $status; /* string */ - public function __construct(array $data = null) { + public function __construct(array $data = null) { $this->id = $data["id"]; $this->category = $data["category"]; $this->name = $data["name"]; $this->photo_urls = $data["photo_urls"]; $this->tags = $data["tags"]; $this->status = $data["status"]; - } + } - public function offsetExists($offset) { + public function offsetExists($offset) { return isset($this->$offset); - } + } - public function offsetGet($offset) { + public function offsetGet($offset) { return $this->$offset; - } + } - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value) { $this->$offset = $value; - } + } - public function offsetUnset($offset) { + public function offsetUnset($offset) { unset($this->$offset); - } - } - + } +} diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/models/Tag.php b/samples/client/petstore/php/SwaggerClient-php/lib/models/Tag.php index 7ae6cc68a3c..309d4087088 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/models/Tag.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/models/Tag.php @@ -15,7 +15,6 @@ * limitations under the License. */ - /** * * @@ -30,37 +29,36 @@ use \ArrayAccess; class Tag implements ArrayAccess { static $swaggerTypes = array( 'id' => 'int', - 'name' => 'string' - ); + 'name' => 'string' + ); - static $attributeMap = array( - 'id' => 'id', - 'name' => 'name' - ); + static $attributeMap = array( + 'id' => 'id', + 'name' => 'name' + ); - - public $id; /* int */ - public $name; /* string */ + + public $id; /* int */ + public $name; /* string */ - public function __construct(array $data = null) { + public function __construct(array $data = null) { $this->id = $data["id"]; $this->name = $data["name"]; - } + } - public function offsetExists($offset) { + public function offsetExists($offset) { return isset($this->$offset); - } + } - public function offsetGet($offset) { + public function offsetGet($offset) { return $this->$offset; - } + } - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value) { $this->$offset = $value; - } + } - public function offsetUnset($offset) { + public function offsetUnset($offset) { unset($this->$offset); - } - } - + } +} diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/models/User.php b/samples/client/petstore/php/SwaggerClient-php/lib/models/User.php index a705c55af74..bbdaa1082b4 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/models/User.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/models/User.php @@ -15,7 +15,6 @@ * limitations under the License. */ - /** * * @@ -30,40 +29,40 @@ use \ArrayAccess; class User implements ArrayAccess { static $swaggerTypes = array( 'id' => 'int', - 'username' => 'string', - 'first_name' => 'string', - 'last_name' => 'string', - 'email' => 'string', - 'password' => 'string', - 'phone' => 'string', - 'user_status' => 'int' - ); + 'username' => 'string', + 'first_name' => 'string', + 'last_name' => 'string', + 'email' => 'string', + 'password' => 'string', + 'phone' => 'string', + 'user_status' => 'int' + ); - static $attributeMap = array( - 'id' => 'id', - 'username' => 'username', - 'first_name' => 'firstName', - 'last_name' => 'lastName', - 'email' => 'email', - 'password' => 'password', - 'phone' => 'phone', - 'user_status' => 'userStatus' - ); + static $attributeMap = array( + 'id' => 'id', + 'username' => 'username', + 'first_name' => 'firstName', + 'last_name' => 'lastName', + 'email' => 'email', + 'password' => 'password', + 'phone' => 'phone', + 'user_status' => 'userStatus' + ); - - public $id; /* int */ - public $username; /* string */ - public $first_name; /* string */ - public $last_name; /* string */ - public $email; /* string */ - public $password; /* string */ - public $phone; /* string */ - /** - * User Status - */ - public $user_status; /* int */ + + public $id; /* int */ + public $username; /* string */ + public $first_name; /* string */ + public $last_name; /* string */ + public $email; /* string */ + public $password; /* string */ + public $phone; /* string */ + /** + * User Status + */ + public $user_status; /* int */ - public function __construct(array $data = null) { + public function __construct(array $data = null) { $this->id = $data["id"]; $this->username = $data["username"]; $this->first_name = $data["first_name"]; @@ -72,22 +71,21 @@ class User implements ArrayAccess { $this->password = $data["password"]; $this->phone = $data["phone"]; $this->user_status = $data["user_status"]; - } + } - public function offsetExists($offset) { + public function offsetExists($offset) { return isset($this->$offset); - } + } - public function offsetGet($offset) { + public function offsetGet($offset) { return $this->$offset; - } + } - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value) { $this->$offset = $value; - } + } - public function offsetUnset($offset) { + public function offsetUnset($offset) { unset($this->$offset); - } - } - + } +}