php Swagger-Client-ObjectSerializer类(方法)实例源码

下面列出了php Swagger-Client-ObjectSerializer 类(方法)源码代码实例,从而了解它的用法。

作者:mateuszmackowia    项目:swagger-codege   
public function testSanitizeFilename()
 {
     // initialize the API client
     $s = new ObjectSerializer();
     $this->assertSame("sun.gif", $s->sanitizeFilename("sun.gif"));
     $this->assertSame("sun.gif", $s->sanitizeFilename("../sun.gif"));
     $this->assertSame("sun.gif", $s->sanitizeFilename("/var/tmp/sun.gif"));
     $this->assertSame("sun.gif", $s->sanitizeFilename("./sun.gif"));
     $this->assertSame("sun", $s->sanitizeFilename("sun"));
     $this->assertSame("sun.gif", $s->sanitizeFilename("..\\sun.gif"));
     $this->assertSame("sun.gif", $s->sanitizeFilename("\var\tmp\\sun.gif"));
     $this->assertSame("sun.gif", $s->sanitizeFilename("c:\var\tmp\\sun.gif"));
     $this->assertSame("sun.gif", $s->sanitizeFilename(".\\sun.gif"));
 }

作者:MyPureClou    项目:swagger-codege   
/**
  * Gets the string presentation of the object
  * @return string
  */
 public function __toString()
 {
     if (defined('JSON_PRETTY_PRINT')) {
         // use JSON pretty print
         return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT);
     }
     return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this));
 }

作者:SocialSuperstor    项目:swagger-codege   
/**
  * getOrderByIdWithHttpInfo
  *
  * Find purchase order by ID
  *
  * @param string $order_id ID of pet that needs to be fetched (required)
  * @return Array of \Swagger\Client\Model\Order, HTTP status code, HTTP response headers (array of strings)
  * @throws \Swagger\Client\ApiException on non-2xx response
  */
 public function getOrderByIdWithHttpInfo($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}";
     $httpBody = '';
     $queryParams = array();
     $headerParams = array();
     $formParams = array();
     $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
     if (!is_null($_header_accept)) {
         $headerParams['Accept'] = $_header_accept;
     }
     $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
     // path params
     if ($order_id !== null) {
         $resourcePath = str_replace("{" . "orderId" . "}", $this->apiClient->getSerializer()->toPathValue($order_id), $resourcePath);
     }
     // default format to json
     $resourcePath = str_replace("{format}", "json", $resourcePath);
     // for model (json/xml)
     if (isset($_tempBody)) {
         $httpBody = $_tempBody;
         // $_tempBody is the method argument, if present
     } elseif (count($formParams) > 0) {
         $httpBody = $formParams;
         // for HTTP post (form)
     }
     // this endpoint requires API key authentication
     $apiKey = $this->apiClient->getApiKeyWithPrefix('test_api_key_header');
     if (strlen($apiKey) !== 0) {
         $headerParams['test_api_key_header'] = $apiKey;
     }
     // this endpoint requires API key authentication
     $apiKey = $this->apiClient->getApiKeyWithPrefix('test_api_key_query');
     if (strlen($apiKey) !== 0) {
         $queryParams['test_api_key_query'] = $apiKey;
     }
     // make the API Call
     try {
         list($response, $statusCode, $httpHeader) = $this->apiClient->callApi($resourcePath, 'GET', $queryParams, $httpBody, $headerParams, '\\Swagger\\Client\\Model\\Order');
         if (!$response) {
             return array(null, $statusCode, $httpHeader);
         }
         return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\\Swagger\\Client\\Model\\Order', $httpHeader), $statusCode, $httpHeader);
     } catch (ApiException $e) {
         switch ($e->getCode()) {
             case 200:
                 $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\\Swagger\\Client\\Model\\Order', $e->getResponseHeaders());
                 $e->setResponseObject($data);
                 break;
         }
         throw $e;
     }
 }

作者:profitbrick    项目:profitbricks-sdk-ph   
/**
  * updateWithHttpInfo
  *
  * Modify a Lan
  *
  * @param string $datacenter_id  (required)
  * @param map[string,string] $lan_id  (required)
  * @param \Swagger\Client\Model\Lan $lan Modified Lan (required)
  * @param bool $pretty_print_query_parameter Controls whether response is pretty-printed (with indentation and new lines) (optional, default to true)
  * @param int $depth Controls the details depth of response objects. \nEg. GET /datacenters/[ID]\n\t- depth=0: only direct properties are included. Children (servers etc.) are not included\n\t- depth=1: direct properties and children references are included\n\t- depth=2: direct properties and children properties are included\n\t- depth=3: direct properties and children properties and children's children are included\n\t- depth=... and so on (optional, default to 0)
  * @return Array of \Swagger\Client\Model\Lan, HTTP status code, HTTP response headers (array of strings)
  * @throws \Swagger\Client\ApiException on non-2xx response
  */
 public function updateWithHttpInfo($datacenter_id, $lan_id, $lan, $pretty_print_query_parameter = null, $depth = null)
 {
     // verify the required parameter 'datacenter_id' is set
     if ($datacenter_id === null) {
         throw new \InvalidArgumentException('Missing the required parameter $datacenter_id when calling update');
     }
     // verify the required parameter 'lan_id' is set
     if ($lan_id === null) {
         throw new \InvalidArgumentException('Missing the required parameter $lan_id when calling update');
     }
     // verify the required parameter 'lan' is set
     if ($lan === null) {
         throw new \InvalidArgumentException('Missing the required parameter $lan when calling update');
     }
     // parse inputs
     $resourcePath = "/datacenters/{datacenterId}/lans/{lanId}";
     $httpBody = '';
     $queryParams = array();
     $headerParams = array();
     $formParams = array();
     $_header_accept = ApiClient::selectHeaderAccept(array('application/json'));
     if (!is_null($_header_accept)) {
         $headerParams['Accept'] = $_header_accept;
     }
     $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/json'));
     // query params
     if ($pretty_print_query_parameter !== null) {
         $queryParams['Pretty print query parameter'] = $this->apiClient->getSerializer()->toQueryValue($pretty_print_query_parameter);
     }
     // query params
     if ($depth !== null) {
         $queryParams['depth'] = $this->apiClient->getSerializer()->toQueryValue($depth);
     }
     // path params
     if ($datacenter_id !== null) {
         $resourcePath = str_replace("{" . "datacenterId" . "}", $this->apiClient->getSerializer()->toPathValue($datacenter_id), $resourcePath);
     }
     // path params
     if ($lan_id !== null) {
         $resourcePath = str_replace("{" . "lanId" . "}", $this->apiClient->getSerializer()->toPathValue($lan_id), $resourcePath);
     }
     // default format to json
     $resourcePath = str_replace("{format}", "json", $resourcePath);
     // body params
     $_tempBody = null;
     if (isset($lan)) {
         $_tempBody = $lan;
     }
     // for model (json/xml)
     if (isset($_tempBody)) {
         $httpBody = $_tempBody;
         // $_tempBody is the method argument, if present
     } elseif (count($formParams) > 0) {
         $httpBody = $formParams;
         // for HTTP post (form)
     }
     // this endpoint requires HTTP basic authentication
     if (strlen($this->apiClient->getConfig()->getUsername()) !== 0 or strlen($this->apiClient->getConfig()->getPassword()) !== 0) {
         $headerParams['Authorization'] = 'Basic ' . base64_encode($this->apiClient->getConfig()->getUsername() . ":" . $this->apiClient->getConfig()->getPassword());
     }
     // make the API Call
     try {
         list($response, $statusCode, $httpHeader) = $this->apiClient->callApi($resourcePath, 'PUT', $queryParams, $httpBody, $headerParams, '\\Swagger\\Client\\Model\\Lan');
         if (!$response) {
             return array(null, $statusCode, $httpHeader);
         }
         return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\\Swagger\\Client\\Model\\Lan', $httpHeader), $statusCode, $httpHeader);
     } catch (ApiException $e) {
         switch ($e->getCode()) {
             case 202:
                 $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\\Swagger\\Client\\Model\\Lan', $e->getResponseHeaders());
                 $e->setResponseObject($data);
                 break;
             default:
                 $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\\Swagger\\Client\\Model\\Error', $e->getResponseHeaders());
                 $e->setResponseObject($data);
                 break;
         }
         throw $e;
     }
 }

作者:CallContro    项目:CallControlClien   
/**
  * complaintsComplaintsWithHttpInfo
  *
  * Complaints: Free service (with registration), providing community and government complaint lookup by phone number for up to 2,000 queries per month.  Details include number complaint rates from (FTC, FCC, IRS, Indiana Attorney  General) and key entity tag extractions from complaints.
  *
  * @param string $phone_number phone number to search (required)
  * @return Array of \Swagger\Client\Model\Complaints, HTTP status code, HTTP response headers (array of strings)
  * @throws \Swagger\Client\ApiException on non-2xx response
  */
 public function complaintsComplaintsWithHttpInfo($phone_number)
 {
     // verify the required parameter 'phone_number' is set
     if ($phone_number === null) {
         throw new \InvalidArgumentException('Missing the required parameter $phone_number when calling complaintsComplaints');
     }
     // parse inputs
     $resourcePath = "/api/2015-11-01/Complaints/{phoneNumber}";
     $httpBody = '';
     $queryParams = array();
     $headerParams = array();
     $formParams = array();
     $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'text/json', 'application/xml', 'text/xml'));
     if (!is_null($_header_accept)) {
         $headerParams['Accept'] = $_header_accept;
     }
     $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
     // path params
     if ($phone_number !== null) {
         $resourcePath = str_replace("{" . "phoneNumber" . "}", $this->apiClient->getSerializer()->toPathValue($phone_number), $resourcePath);
     }
     // default format to json
     $resourcePath = str_replace("{format}", "json", $resourcePath);
     // for model (json/xml)
     if (isset($_tempBody)) {
         $httpBody = $_tempBody;
         // $_tempBody is the method argument, if present
     } elseif (count($formParams) > 0) {
         $httpBody = $formParams;
         // for HTTP post (form)
     }
     // make the API Call
     try {
         list($response, $statusCode, $httpHeader) = $this->apiClient->callApi($resourcePath, 'GET', $queryParams, $httpBody, $headerParams, '\\Swagger\\Client\\Model\\Complaints');
         if (!$response) {
             return array(null, $statusCode, $httpHeader);
         }
         return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\\Swagger\\Client\\Model\\Complaints', $httpHeader), $statusCode, $httpHeader);
     } catch (ApiException $e) {
         switch ($e->getCode()) {
             case 200:
                 $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\\Swagger\\Client\\Model\\Complaints', $e->getResponseHeaders());
                 $e->setResponseObject($data);
                 break;
         }
         throw $e;
     }
 }

作者:DerPat    项目:swagger-codege   
/**
  * Make the HTTP call (Sync)
  * @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
  * @param string $responseType expected response type of the endpoint
  * @throws \Swagger\Client\ApiException on a non 2xx response
  * @return mixed
  */
 public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType = null)
 {
     $headers = array();
     // construct the http header
     $headerParams = array_merge((array) $this->config->getDefaultHeaders(), (array) $headerParams);
     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);
     } elseif ((is_object($postData) or is_array($postData)) and !in_array('Content-Type: multipart/form-data', $headers)) {
         // json model
         $postData = json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($postData));
     }
     $url = $this->config->getHost() . $resourcePath;
     $curl = curl_init();
     // set timeout, if needed
     if ($this->config->getCurlTimeout() != 0) {
         curl_setopt($curl, CURLOPT_TIMEOUT, $this->config->getCurlTimeout());
     }
     // return the result on success, rather than just true
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
     // disable SSL verification, if needed
     if ($this->config->getSSLVerification() == false) {
         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
         curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
     }
     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);
     } elseif ($method == self::$HEAD) {
         curl_setopt($curl, CURLOPT_NOBODY, true);
     } elseif ($method == self::$OPTIONS) {
         curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "OPTIONS");
         curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
     } elseif ($method == self::$PATCH) {
         curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH");
         curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
     } elseif ($method == self::$PUT) {
         curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
         curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
     } elseif ($method == self::$DELETE) {
         curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
         curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
     } elseif ($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->config->getUserAgent());
     // debugging for curl
     if ($this->config->getDebug()) {
         error_log("[DEBUG] HTTP Request body  ~BEGIN~\n" . print_r($postData, true) . "\n~END~\n", 3, $this->config->getDebugFile());
         curl_setopt($curl, CURLOPT_VERBOSE, 1);
         curl_setopt($curl, CURLOPT_STDERR, fopen($this->config->getDebugFile(), 'a'));
     } else {
         curl_setopt($curl, CURLOPT_VERBOSE, 0);
     }
     // 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 = $this->http_parse_headers(substr($response, 0, $http_header_size));
     $http_body = substr($response, $http_header_size);
     $response_info = curl_getinfo($curl);
     // debug HTTP response body
     if ($this->config->getDebug()) {
         error_log("[DEBUG] HTTP Response body ~BEGIN~\n" . print_r($http_body, true) . "\n~END~\n", 3, $this->config->getDebugFile());
     }
     // Handle the response
     if ($response_info['http_code'] == 0) {
         throw new ApiException("API call to {$url} timed out: " . serialize($response_info), 0, null, null);
     } elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299) {
         // return raw body if response is a file
         if ($responseType == '\\SplFileObject' || $responseType == 'string') {
             return array($http_body, $response_info['http_code'], $http_header);
         }
         $data = json_decode($http_body);
         if (json_last_error() > 0) {
             // if response is a string
             $data = $http_body;
         }
     } else {
//.........这里部分代码省略.........

作者:wing32    项目:petstore-ph   
/**
  * getPetsWithHttpInfo
  *
  * Get your pets
  *
  * @return Array of \Swagger\Client\Model\Animal, HTTP status code, HTTP response headers (array of strings)
  * @throws \Swagger\Client\ApiException on non-2xx response
  */
 public function getPetsWithHttpInfo()
 {
     // parse inputs
     $resourcePath = "/pets";
     $httpBody = '';
     $queryParams = array();
     $headerParams = array();
     $formParams = array();
     $_header_accept = ApiClient::selectHeaderAccept(array('application/json'));
     if (!is_null($_header_accept)) {
         $headerParams['Accept'] = $_header_accept;
     }
     $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/x-www-form-urlencoded'));
     // default format to json
     $resourcePath = str_replace("{format}", "json", $resourcePath);
     // for model (json/xml)
     if (isset($_tempBody)) {
         $httpBody = $_tempBody;
         // $_tempBody is the method argument, if present
     } elseif (count($formParams) > 0) {
         $httpBody = $formParams;
         // for HTTP post (form)
     }
     // make the API Call
     try {
         list($response, $statusCode, $httpHeader) = $this->apiClient->callApi($resourcePath, 'GET', $queryParams, $httpBody, $headerParams, '\\Swagger\\Client\\Model\\Animal');
         if (!$response) {
             return array(null, $statusCode, $httpHeader);
         }
         return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\\Swagger\\Client\\Model\\Animal', $httpHeader, 'className'), $statusCode, $httpHeader);
     } catch (ApiException $e) {
         switch ($e->getCode()) {
             case 200:
                 $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\\Swagger\\Client\\Model\\Animal', $e->getResponseHeaders());
                 $e->setResponseObject($data);
                 break;
         }
         throw $e;
     }
 }

作者:CloudBoos    项目:swagge   
/**
  * signUpWithHttpInfo
  *
  * create a new user
  *
  * @param string $app_id ID of app (required)
  * @param \Swagger\Client\Model\UserBody $body request body (required)
  * @return Array of \Swagger\Client\Model\CloudUser, HTTP status code, HTTP response headers (array of strings)
  * @throws \Swagger\Client\ApiException on non-2xx response
  */
 public function signUpWithHttpInfo($app_id, $body)
 {
     // verify the required parameter 'app_id' is set
     if ($app_id === null) {
         throw new \InvalidArgumentException('Missing the required parameter $app_id when calling signUp');
     }
     // verify the required parameter 'body' is set
     if ($body === null) {
         throw new \InvalidArgumentException('Missing the required parameter $body when calling signUp');
     }
     // parse inputs
     $resourcePath = "user/{app_id}/signup";
     $httpBody = '';
     $queryParams = array();
     $headerParams = array();
     $formParams = array();
     $_header_accept = ApiClient::selectHeaderAccept(array('application/json'));
     if (!is_null($_header_accept)) {
         $headerParams['Accept'] = $_header_accept;
     }
     $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/json'));
     // path params
     if ($app_id !== null) {
         $resourcePath = str_replace("{" . "app_id" . "}", $this->apiClient->getSerializer()->toPathValue($app_id), $resourcePath);
     }
     // default format to json
     $resourcePath = str_replace("{format}", "json", $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
     } elseif (count($formParams) > 0) {
         $httpBody = $formParams;
         // for HTTP post (form)
     }
     // make the API Call
     try {
         list($response, $statusCode, $httpHeader) = $this->apiClient->callApi($resourcePath, 'POST', $queryParams, $httpBody, $headerParams, '\\Swagger\\Client\\Model\\CloudUser');
         if (!$response) {
             return array(null, $statusCode, $httpHeader);
         }
         return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\\Swagger\\Client\\Model\\CloudUser', $httpHeader), $statusCode, $httpHeader);
     } catch (ApiException $e) {
         switch ($e->getCode()) {
             case 200:
                 $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\\Swagger\\Client\\Model\\CloudUser', $e->getResponseHeaders());
                 $e->setResponseObject($data);
                 break;
         }
         throw $e;
     }
 }

作者:mateuszmackowia    项目:swagger-codege   
public function testDeserializationOfMapOfMapOfOrder()
    {
        $order_json = <<<ORDER
{
  "test": {
    "test2": {
      "id": 10,
      "petId": 20,
      "quantity": 30,
      "shipDate": "2015-08-22T07:13:36.613Z",
      "status": "placed",
      "complete": false
    }
  }
}
ORDER;
        $order = \Swagger\Client\ObjectSerializer::deserialize(json_decode($order_json), 'map[string,map[string,\\Swagger\\Client\\Model\\Order]]');
        $this->assertArrayHasKey('test', $order);
        $this->assertArrayHasKey('test2', $order['test']);
        $_order = $order['test']['test2'];
        $this->assertInstanceOf('Swagger\\Client\\Model\\Order', $_order);
        $this->assertSame(10, $_order->getId());
        $this->assertSame(20, $_order->getPetId());
        $this->assertSame(30, $_order->getQuantity());
        $this->assertTrue(new \DateTime("2015-08-22T07:13:36.613Z") == $_order->getShipDate());
        $this->assertSame("placed", $_order->getStatus());
        $this->assertSame(false, $_order->getComplete());
    }

作者:MarekMateja    项目:swagger-codege   
/**
  * loginUserWithHttpInfo
  *
  * Logs user into the system
  *
  * @param string $username The user name for login (optional)
  * @param string $password The password for login in clear text (optional)
  * @return Array of string, HTTP status code, HTTP response headers (array of strings)
  * @throws \Swagger\Client\ApiException on non-2xx response
  */
 public function loginUserWithHttpInfo($username = null, $password = null)
 {
     // parse inputs
     $resourcePath = "/user/login";
     $httpBody = '';
     $queryParams = array();
     $headerParams = array();
     $formParams = array();
     $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
     if (!is_null($_header_accept)) {
         $headerParams['Accept'] = $_header_accept;
     }
     $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
     // query params
     if ($username !== null) {
         $queryParams['username'] = $this->apiClient->getSerializer()->toQueryValue($username);
     }
     // query params
     if ($password !== null) {
         $queryParams['password'] = $this->apiClient->getSerializer()->toQueryValue($password);
     }
     // default format to json
     $resourcePath = str_replace("{format}", "json", $resourcePath);
     // for model (json/xml)
     if (isset($_tempBody)) {
         $httpBody = $_tempBody;
         // $_tempBody is the method argument, if present
     } elseif (count($formParams) > 0) {
         $httpBody = $formParams;
         // for HTTP post (form)
     }
     // make the API Call
     try {
         list($response, $statusCode, $httpHeader) = $this->apiClient->callApi($resourcePath, 'GET', $queryParams, $httpBody, $headerParams, 'string');
         if (!$response) {
             return array(null, $statusCode, $httpHeader);
         }
         return array(\Swagger\Client\ObjectSerializer::deserialize($response, 'string', $httpHeader), $statusCode, $httpHeader);
     } catch (ApiException $e) {
         switch ($e->getCode()) {
             case 200:
                 $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), 'string', $e->getResponseHeaders());
                 $e->setResponseObject($data);
                 break;
         }
         throw $e;
     }
 }

作者:MarekMateja    项目:swagger-codege   
/**
  * placeOrderWithHttpInfo
  *
  * Place an order for a pet
  *
  * @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (optional)
  * @return Array of \Swagger\Client\Model\Order, HTTP status code, HTTP response headers (array of strings)
  * @throws \Swagger\Client\ApiException on non-2xx response
  */
 public function placeOrderWithHttpInfo($body = null)
 {
     // parse inputs
     $resourcePath = "/store/order";
     $httpBody = '';
     $queryParams = array();
     $headerParams = array();
     $formParams = array();
     $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
     if (!is_null($_header_accept)) {
         $headerParams['Accept'] = $_header_accept;
     }
     $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
     // default format to json
     $resourcePath = str_replace("{format}", "json", $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
     } elseif (count($formParams) > 0) {
         $httpBody = $formParams;
         // for HTTP post (form)
     }
     // this endpoint requires API key authentication
     $apiKey = $this->apiClient->getApiKeyWithPrefix('x-test_api_client_id');
     if (strlen($apiKey) !== 0) {
         $headerParams['x-test_api_client_id'] = $apiKey;
     }
     // this endpoint requires API key authentication
     $apiKey = $this->apiClient->getApiKeyWithPrefix('x-test_api_client_secret');
     if (strlen($apiKey) !== 0) {
         $headerParams['x-test_api_client_secret'] = $apiKey;
     }
     // make the API Call
     try {
         list($response, $statusCode, $httpHeader) = $this->apiClient->callApi($resourcePath, 'POST', $queryParams, $httpBody, $headerParams, '\\Swagger\\Client\\Model\\Order');
         if (!$response) {
             return array(null, $statusCode, $httpHeader);
         }
         return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\\Swagger\\Client\\Model\\Order', $httpHeader), $statusCode, $httpHeader);
     } catch (ApiException $e) {
         switch ($e->getCode()) {
             case 200:
                 $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\\Swagger\\Client\\Model\\Order', $e->getResponseHeaders());
                 $e->setResponseObject($data);
                 break;
         }
         throw $e;
     }
 }


问题


面经


文章

微信
公众号

扫码关注公众号