Update sample client

This commit is contained in:
Branden Cash
2015-06-12 15:01:25 -07:00
parent 8ed690cad0
commit 719a0b732e
15 changed files with 1551 additions and 141 deletions

View File

@@ -1,13 +0,0 @@
<?php
// load models defined for endpoints
foreach (glob(dirname(__FILE__)."/lib/models/*.php") as $filename)
{
require_once $filename;
}
// load classes for accessing the endpoints
foreach (glob(dirname(__FILE__)."/lib/*.php") as $filename)
{
require_once $filename;
}
?>

View File

@@ -0,0 +1,41 @@
<?php
/**
* An example of a project-specific implementation.
*
* After registering this autoload function with SPL, the following line
* would cause the function to attempt to load the \Swagger\Client\Baz\Qux class
* from /path/to/project/lib/Baz/Qux.php:
*
* new \Swagger\Client\Baz\Qux;
*
* @param string $class The fully-qualified class name.
* @return void
*/
spl_autoload_register(function ($class) {
// project-specific namespace prefix
$prefix = 'Swagger\\Client\\';
// base directory for the namespace prefix
$base_dir = __DIR__ . '/lib/';
// does the class use the namespace prefix?
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
// no, move to the next registered autoloader
return;
}
// get the relative class name
$relative_class = substr($class, $len);
// replace the namespace prefix with the base directory, replace namespace
// separators with directory separators in the relative class name, append
// with .php
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
// if the file exists, require it
if (file_exists($file)) {
require $file;
}
});

View File

@@ -1,5 +1,5 @@
{ {
"name": "SwaggerClient/SwaggerClient-php", "name": "swagger/swagger-client",
"description": "", "description": "",
"keywords": [ "keywords": [
"swagger", "swagger",
@@ -27,6 +27,6 @@
"squizlabs/php_codesniffer": "~2.0" "squizlabs/php_codesniffer": "~2.0"
}, },
"autoload": { "autoload": {
"psr-4": { "SwaggerClient\\" : "lib/" } "psr-4": { "Swagger\\Client\\" : "lib/" }
} }
} }

View File

@@ -0,0 +1,541 @@
<?php
/**
* Copyright 2015 SmartBear Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
*/
namespace Swagger\Client\Api;
use \Swagger\Client\ApiClient;
use \Swagger\Client\Configuration;
class PetApi {
/**
* @param \Swagger\Client\ApiClient|null $apiClient The api client to use. Defaults to getting it from Configuration
*/
function __construct($apiClient = null) {
if (null === $apiClient) {
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
/**
* @return \Swagger\Client\ApiClient get the API client
*/
public function getApiClient() {
return $this->apiClient;
}
/**
* @param \Swagger\Client $apiClient set the API client
*/
public function setApiClient($apiClient) {
$this->apiClient = $apiClient;
}
/**
* updatePet
*
* Update an existing pet
*
* @param \Swagger\Client\Model\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;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/json','application/xml'));
// 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('petstore_auth');
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
}
/**
* addPet
*
* Add a new pet to the store
*
* @param \Swagger\Client\Model\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 = "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;
}
// 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);
}
/**
* findPetsByStatus
*
* Finds Pets by status
*
* @param string[] $status Status values that need to be considered for filter (required)
* @return \Swagger\Client\Model\Pet[]
*/
public function findPetsByStatus($status) {
// 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());
// 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;
}
// 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,'\Swagger\Client\Model\Pet[]');
return $responseObject;
}
/**
* findPetsByTags
*
* Finds Pets by tags
*
* @param string[] $tags Tags to filter by (required)
* @return \Swagger\Client\Model\Pet[]
*/
public function findPetsByTags($tags) {
// 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());
// 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,'\Swagger\Client\Model\Pet[]');
return $responseObject;
}
/**
* getPetById
*
* Find pet by ID
*
* @param int $pet_id ID of pet that needs to be fetched (required)
* @return \Swagger\Client\Model\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());
// 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;
}
// authentication setting, if any
$authSettings = array('api_key', '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,'\Swagger\Client\Model\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'));
// 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;
}
// authentication setting, if any
$authSettings = array('petstore_auth');
// 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) {
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());
// 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;
}
// authentication setting, if any
$authSettings = array('petstore_auth');
// 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) {
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'));
// 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;
}
// authentication setting, if any
$authSettings = array('petstore_auth');
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
}
}

View File

@@ -0,0 +1,296 @@
<?php
/**
* Copyright 2015 SmartBear Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
*/
namespace Swagger\Client\Api;
use \Swagger\Client\ApiClient;
use \Swagger\Client\Configuration;
class StoreApi {
/**
* @param \Swagger\Client\ApiClient|null $apiClient The api client to use. Defaults to getting it from Configuration
*/
function __construct($apiClient = null) {
if (null === $apiClient) {
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
/**
* @return \Swagger\Client\ApiClient get the API client
*/
public function getApiClient() {
return $this->apiClient;
}
/**
* @param \Swagger\Client $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;
}
$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('api_key');
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
if(! $response) {
return null;
}
$responseObject = $this->apiClient->deserialize($response,'map[string,int]');
return $responseObject;
}
/**
* placeOrder
*
* Place an order for a pet
*
* @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (required)
* @return \Swagger\Client\Model\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());
// 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,'\Swagger\Client\Model\Order');
return $responseObject;
}
/**
* getOrderById
*
* Find purchase order by ID
*
* @param string $order_id ID of pet that needs to be fetched (required)
* @return \Swagger\Client\Model\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());
// 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;
}
// 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,'\Swagger\Client\Model\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());
// 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;
}
// authentication setting, if any
$authSettings = array();
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
}
}

View File

@@ -0,0 +1,516 @@
<?php
/**
* Copyright 2015 SmartBear Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
*
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
*/
namespace Swagger\Client\Api;
use \Swagger\Client\ApiClient;
use \Swagger\Client\Configuration;
class UserApi {
/**
* @param \Swagger\Client\ApiClient|null $apiClient The api client to use. Defaults to getting it from Configuration
*/
function __construct($apiClient = null) {
if (null === $apiClient) {
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
/**
* @return \Swagger\Client\ApiClient get the API client
*/
public function getApiClient() {
return $this->apiClient;
}
/**
* @param \Swagger\Client $apiClient set the API client
*/
public function setApiClient($apiClient) {
$this->apiClient = $apiClient;
}
/**
* createUser
*
* Create user
*
* @param \Swagger\Client\Model\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;
}
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
// 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);
}
/**
* createUsersWithArrayInput
*
* Creates list of users with given input array
*
* @param \Swagger\Client\Model\User[] $body List of user object (required)
* @return void
*/
public function createUsersWithArrayInput($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());
// 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);
}
/**
* createUsersWithListInput
*
* Creates list of users with given input array
*
* @param \Swagger\Client\Model\User[] $body List of user object (required)
* @return void
*/
public function createUsersWithListInput($body) {
// 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;
}
// 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);
}
/**
* 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/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());
// 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;
}
// 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,'string');
return $responseObject;
}
/**
* logoutUser
*
* Logs out current logged in user session
*
* @return void
*/
public function logoutUser() {
// 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 \Swagger\Client\Model\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());
// 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;
}
// 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,'\Swagger\Client\Model\User');
return $responseObject;
}
/**
* updateUser
*
* Updated user
*
* @param string $username name that need to be deleted (required)
* @param \Swagger\Client\Model\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());
// 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;
}
// authentication setting, if any
$authSettings = array();
// 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) {
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());
// 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;
}
// authentication setting, if any
$authSettings = array();
// make the API Call
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $httpBody,
$headerParams, $authSettings);
}
}

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
namespace SwaggerClient; namespace Swagger\Client;
class ApiClient { class ApiClient {
@@ -24,17 +24,14 @@ class ApiClient {
public static $GET = "GET"; public static $GET = "GET";
public static $PUT = "PUT"; public static $PUT = "PUT";
public static $DELETE = "DELETE"; public static $DELETE = "DELETE";
/** @var string[] Array of default headers where the key is the header name and the value is the header value */
private $default_header = array(); private $default_header = array();
/* /** @var string timeout (second) of the HTTP request, by default set to 0, no timeout */
* @var string timeout (second) of the HTTP request, by default set to 0, no timeout
*/
protected $curl_timeout = 0; protected $curl_timeout = 0;
/* /** @var string user agent of the HTTP request, set to "PHP-Swagger" by default */
* @var string user agent of the HTTP request, set to "PHP-Swagger" by default
*/
protected $user_agent = "PHP-Swagger"; protected $user_agent = "PHP-Swagger";
/** /**
@@ -391,8 +388,8 @@ class ApiClient {
$deserialized[$key] = $this->deserialize($value, $subClass); $deserialized[$key] = $this->deserialize($value, $subClass);
} }
} }
} elseif (strcasecmp(substr($class, 0, 6),'array[') == 0) { } elseif (strcasecmp(substr($class, -2),'[]') == 0) {
$subClass = substr($class, 6, -1); $subClass = substr($class, 0, -2);
$values = array(); $values = array();
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
$values[] = $this->deserialize($value, $subClass); $values[] = $this->deserialize($value, $subClass);
@@ -404,7 +401,6 @@ class ApiClient {
settype($data, $class); settype($data, $class);
$deserialized = $data; $deserialized = $data;
} else { } else {
$class = "SwaggerClient\\models\\".$class;
$instance = new $class(); $instance = new $class();
foreach ($instance::$swaggerTypes as $property => $type) { foreach ($instance::$swaggerTypes as $property => $type) {
$original_property_name = $instance::$attributeMap[$property]; $original_property_name = $instance::$attributeMap[$property];

View File

@@ -15,20 +15,16 @@
* limitations under the License. * limitations under the License.
*/ */
namespace SwaggerClient; namespace Swagger\Client;
use \Exception; use \Exception;
class ApiException extends Exception { class ApiException extends Exception {
/** /** @var string The HTTP body of the server response. */
* The HTTP body of the server response.
*/
protected $response_body; protected $response_body;
/** /** @var string[] The HTTP header of the server response. */
* The HTTP header of the server response.
*/
protected $response_headers; protected $response_headers;
public function __construct($message="", $code=0, $responseHeaders=null, $responseBody=null) { public function __construct($message="", $code=0, $responseHeaders=null, $responseBody=null) {

View File

@@ -15,43 +15,31 @@
* limitations under the License. * limitations under the License.
*/ */
namespace SwaggerClient; namespace Swagger\Client;
use \Swagger\Client\ApiClient;
class Configuration { class Configuration {
/** /** @var string[] Associate array to store API key(s) */
* Associate array to store API key(s)
*/
public static $apiKey = array(); public static $apiKey = array();
/** /** string[] Associate array to store API prefix (e.g. Bearer) */
* Associate array to store API prefix (e.g. Bearer)
*/
public static $apiKeyPrefix = array(); public static $apiKeyPrefix = array();
/** /** @var string Username for HTTP basic authentication */
* Username for HTTP basic authentication
*/
public static $username = ''; public static $username = '';
/** /** @var string Password for HTTP basic authentication */
* Password for HTTP basic authentication
*/
public static $password = ''; public static $password = '';
/** /** @var \Swagger\Client\ApiClient The default instance of ApiClient */
* The default instance of ApiClient
*/
public static $apiClient; public static $apiClient;
/** /** @var bool Debug switch (default set to false) */
* Debug switch (default set to false)
*/
public static $debug = false; public static $debug = false;
/** /** @var string Debug file location (log to STDOUT by default) */
* Debug file location (log to STDOUT by default)
*/
public static $debug_file = 'php://output'; public static $debug_file = 'php://output';
/* /*
@@ -63,4 +51,3 @@ class Configuration {
} }
} }

View File

@@ -22,28 +22,35 @@
* *
*/ */
namespace SwaggerClient\models; namespace Swagger\Client\Model;
use \ArrayAccess; use \ArrayAccess;
class Category implements ArrayAccess { class Category implements ArrayAccess {
/** @var string[] Array of property to type mappings. Used for (de)serialization */
static $swaggerTypes = array( static $swaggerTypes = array(
'id' => 'int', 'id' => 'int',
'name' => 'string' 'name' => 'string'
); );
/** @var string[] Array of attributes where the key is the local name, and the value is the original name */
static $attributeMap = array( static $attributeMap = array(
'id' => 'id', 'id' => 'id',
'name' => 'name' 'name' => 'name'
); );
public $id; /* int */ /** @var int $id */
public $name; /* string */ public $id;
/** @var string $name */
public $name;
/**
* @param mixed[] Array of parameters to initialize the object with
*/
public function __construct(array $data = null) { public function __construct(array $data = null) {
$this->id = $data["id"]; $this->id = @$data["id"];
$this->name = $data["name"]; $this->name = @$data["name"];
} }
public function offsetExists($offset) { public function offsetExists($offset) {

View File

@@ -22,20 +22,22 @@
* *
*/ */
namespace SwaggerClient\models; namespace Swagger\Client\Model;
use \ArrayAccess; use \ArrayAccess;
class Order implements ArrayAccess { class Order implements ArrayAccess {
/** @var string[] Array of property to type mappings. Used for (de)serialization */
static $swaggerTypes = array( static $swaggerTypes = array(
'id' => 'int', 'id' => 'int',
'pet_id' => 'int', 'pet_id' => 'int',
'quantity' => 'int', 'quantity' => 'int',
'ship_date' => 'DateTime', 'ship_date' => '\DateTime',
'status' => 'string', 'status' => 'string',
'complete' => 'boolean' 'complete' => 'bool'
); );
/** @var string[] Array of attributes where the key is the local name, and the value is the original name */
static $attributeMap = array( static $attributeMap = array(
'id' => 'id', 'id' => 'id',
'pet_id' => 'petId', 'pet_id' => 'petId',
@@ -44,25 +46,35 @@ class Order implements ArrayAccess {
'status' => 'status', 'status' => 'status',
'complete' => 'complete' 'complete' => 'complete'
); );
public $id; /* int */ /** @var int $id */
public $pet_id; /* int */ public $id;
public $quantity; /* int */
public $ship_date; /* DateTime */ /** @var int $pet_id */
public $pet_id;
/** @var int $quantity */
public $quantity;
/** @var \DateTime $ship_date */
public $ship_date;
/** @var string $status Order Status */
public $status;
/** @var bool $complete */
public $complete;
/** /**
* Order Status * @param mixed[] Array of parameters to initialize the object with
*/ */
public $status; /* string */
public $complete; /* boolean */
public function __construct(array $data = null) { public function __construct(array $data = null) {
$this->id = $data["id"]; $this->id = @$data["id"];
$this->pet_id = $data["pet_id"]; $this->pet_id = @$data["pet_id"];
$this->quantity = $data["quantity"]; $this->quantity = @$data["quantity"];
$this->ship_date = $data["ship_date"]; $this->ship_date = @$data["ship_date"];
$this->status = $data["status"]; $this->status = @$data["status"];
$this->complete = $data["complete"]; $this->complete = @$data["complete"];
} }
public function offsetExists($offset) { public function offsetExists($offset) {

View File

@@ -22,20 +22,22 @@
* *
*/ */
namespace SwaggerClient\models; namespace Swagger\Client\Model;
use \ArrayAccess; use \ArrayAccess;
class Pet implements ArrayAccess { class Pet implements ArrayAccess {
/** @var string[] Array of property to type mappings. Used for (de)serialization */
static $swaggerTypes = array( static $swaggerTypes = array(
'id' => 'int', 'id' => 'int',
'category' => 'Category', 'category' => '\Swagger\Client\Model\Category',
'name' => 'string', 'name' => 'string',
'photo_urls' => 'array[string]', 'photo_urls' => 'string[]',
'tags' => 'array[Tag]', 'tags' => '\Swagger\Client\Model\Tag[]',
'status' => 'string' 'status' => 'string'
); );
/** @var string[] Array of attributes where the key is the local name, and the value is the original name */
static $attributeMap = array( static $attributeMap = array(
'id' => 'id', 'id' => 'id',
'category' => 'category', 'category' => 'category',
@@ -44,25 +46,35 @@ class Pet implements ArrayAccess {
'tags' => 'tags', 'tags' => 'tags',
'status' => 'status' 'status' => 'status'
); );
public $id; /* int */ /** @var int $id */
public $category; /* Category */ public $id;
public $name; /* string */
public $photo_urls; /* array[string] */ /** @var \Swagger\Client\Model\Category $category */
public $tags; /* array[Tag] */ public $category;
/** @var string $name */
public $name;
/** @var string[] $photo_urls */
public $photo_urls;
/** @var \Swagger\Client\Model\Tag[] $tags */
public $tags;
/** @var string $status pet status in the store */
public $status;
/** /**
* pet status in the store * @param mixed[] Array of parameters to initialize the object with
*/ */
public $status; /* string */
public function __construct(array $data = null) { public function __construct(array $data = null) {
$this->id = $data["id"]; $this->id = @$data["id"];
$this->category = $data["category"]; $this->category = @$data["category"];
$this->name = $data["name"]; $this->name = @$data["name"];
$this->photo_urls = $data["photo_urls"]; $this->photo_urls = @$data["photo_urls"];
$this->tags = $data["tags"]; $this->tags = @$data["tags"];
$this->status = $data["status"]; $this->status = @$data["status"];
} }
public function offsetExists($offset) { public function offsetExists($offset) {

View File

@@ -22,28 +22,35 @@
* *
*/ */
namespace SwaggerClient\models; namespace Swagger\Client\Model;
use \ArrayAccess; use \ArrayAccess;
class Tag implements ArrayAccess { class Tag implements ArrayAccess {
/** @var string[] Array of property to type mappings. Used for (de)serialization */
static $swaggerTypes = array( static $swaggerTypes = array(
'id' => 'int', 'id' => 'int',
'name' => 'string' 'name' => 'string'
); );
/** @var string[] Array of attributes where the key is the local name, and the value is the original name */
static $attributeMap = array( static $attributeMap = array(
'id' => 'id', 'id' => 'id',
'name' => 'name' 'name' => 'name'
); );
public $id; /* int */ /** @var int $id */
public $name; /* string */ public $id;
/** @var string $name */
public $name;
/**
* @param mixed[] Array of parameters to initialize the object with
*/
public function __construct(array $data = null) { public function __construct(array $data = null) {
$this->id = $data["id"]; $this->id = @$data["id"];
$this->name = $data["name"]; $this->name = @$data["name"];
} }
public function offsetExists($offset) { public function offsetExists($offset) {

View File

@@ -22,11 +22,12 @@
* *
*/ */
namespace SwaggerClient\models; namespace Swagger\Client\Model;
use \ArrayAccess; use \ArrayAccess;
class User implements ArrayAccess { class User implements ArrayAccess {
/** @var string[] Array of property to type mappings. Used for (de)serialization */
static $swaggerTypes = array( static $swaggerTypes = array(
'id' => 'int', 'id' => 'int',
'username' => 'string', 'username' => 'string',
@@ -38,6 +39,7 @@ class User implements ArrayAccess {
'user_status' => 'int' 'user_status' => 'int'
); );
/** @var string[] Array of attributes where the key is the local name, and the value is the original name */
static $attributeMap = array( static $attributeMap = array(
'id' => 'id', 'id' => 'id',
'username' => 'username', 'username' => 'username',
@@ -48,29 +50,43 @@ class User implements ArrayAccess {
'phone' => 'phone', 'phone' => 'phone',
'user_status' => 'userStatus' 'user_status' => 'userStatus'
); );
public $id; /* int */ /** @var int $id */
public $username; /* string */ public $id;
public $first_name; /* string */
public $last_name; /* string */ /** @var string $username */
public $email; /* string */ public $username;
public $password; /* string */
public $phone; /* string */ /** @var string $first_name */
public $first_name;
/** @var string $last_name */
public $last_name;
/** @var string $email */
public $email;
/** @var string $password */
public $password;
/** @var string $phone */
public $phone;
/** @var int $user_status User Status */
public $user_status;
/** /**
* User Status * @param mixed[] Array of parameters to initialize the object with
*/ */
public $user_status; /* int */
public function __construct(array $data = null) { public function __construct(array $data = null) {
$this->id = $data["id"]; $this->id = @$data["id"];
$this->username = $data["username"]; $this->username = @$data["username"];
$this->first_name = $data["first_name"]; $this->first_name = @$data["first_name"];
$this->last_name = $data["last_name"]; $this->last_name = @$data["last_name"];
$this->email = $data["email"]; $this->email = @$data["email"];
$this->password = $data["password"]; $this->password = @$data["password"];
$this->phone = $data["phone"]; $this->phone = @$data["phone"];
$this->user_status = $data["user_status"]; $this->user_status = @$data["user_status"];
} }
public function offsetExists($offset) { public function offsetExists($offset) {

View File

@@ -1,6 +1,5 @@
<?php <?php
//require_once('vendor/autoload.php'); require_once(__DIR__ . '/SwaggerClient-php/autoload.php');
require_once('SwaggerClient-php/SwaggerClient.php');
// show error reporting // show error reporting
//ini_set('display_errors', 1); //ini_set('display_errors', 1);
@@ -18,7 +17,7 @@ $petId = 10005; // ID of pet that needs to be fetched
try { try {
// get pet by id // get pet by id
//$pet_api = new SwaggerClient\PetAPI($api_client); //$pet_api = new SwaggerClient\PetAPI($api_client);
$pet_api = new SwaggerClient\PetAPI(); $pet_api = new Swagger\Client\Api\PetAPI();
// test default header // test default header
$pet_api->getApiClient()->addDefaultHeader("TEST_API_KEY", "09182sdkanafndsl903"); $pet_api->getApiClient()->addDefaultHeader("TEST_API_KEY", "09182sdkanafndsl903");
// return Pet (model) // return Pet (model)
@@ -28,34 +27,31 @@ try {
// add pet (post json) // add pet (post json)
$new_pet_id = 10005; $new_pet_id = 10005;
$new_pet = new SwaggerClient\models\Pet; $new_pet = new Swagger\Client\Model\Pet;
$new_pet->id = $new_pet_id; $new_pet->id = $new_pet_id;
$new_pet->name = "PHP Unit Test"; $new_pet->name = "PHP Unit Test";
// new tag // new tag
$tag= new SwaggerClient\models\Tag; $tag= new Swagger\Client\Model\Tag;
$tag->id = $new_pet_id; // use the same id as pet $tag->id = $new_pet_id; // use the same id as pet
//$tag->name = "test php tag"; //$tag->name = "test php tag";
// new category // new category
$category = new SwaggerClient\models\Category; $category = new Swagger\Client\Model\Category;
$category->id = 0; // use the same id as pet $category->id = 0; // use the same id as pet
//$category->name = "test php category"; //$category->name = "test php category";
$new_pet->tags = array($tag); $new_pet->tags = array($tag);
$new_pet->category = $category; $new_pet->category = $category;
$pet_api = new SwaggerClient\PetAPI(); $pet_api = new Swagger\Client\Api\PetAPI();
// add a new pet (model) // add a new pet (model)
$add_response = $pet_api->addPet($new_pet); $add_response = $pet_api->addPet($new_pet);
// test upload file (exception) // test upload file (exception)
$upload_response = $pet_api->uploadFile($petId, "test meta", NULL); $upload_response = $pet_api->uploadFile($petId, "test meta", NULL);
} catch (Exception $e) { } catch (Swagger\Client\Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n"; echo 'Caught exception: ', $e->getMessage(), "\n";
echo 'HTTP response headers: ', $e->getResponseHeaders(), "\n"; echo 'HTTP response headers: ', $e->getResponseHeaders(), "\n";
echo 'HTTP response body: ', $e->getResponseBody(), "\n"; echo 'HTTP response body: ', $e->getResponseBody(), "\n";
echo 'HTTP status code: ', $e->getCode(), "\n"; echo 'HTTP status code: ', $e->getCode(), "\n";
} }
?>