add enum support for model property

This commit is contained in:
wing328
2015-07-02 16:17:36 +08:00
parent 38149173ff
commit 71a22141bf
11 changed files with 93 additions and 41 deletions

View File

@@ -72,7 +72,7 @@ class PetApi {
*/
public function updatePet($body) {
// parse inputs
$resourcePath = "/pet";
$resourcePath = str_replace("{format}", "json", $resourcePath);
@@ -133,7 +133,7 @@ class PetApi {
*/
public function addPet($body) {
// parse inputs
$resourcePath = "/pet";
$resourcePath = str_replace("{format}", "json", $resourcePath);
@@ -194,7 +194,7 @@ class PetApi {
*/
public function findPetsByStatus($status) {
// parse inputs
$resourcePath = "/pet/findByStatus";
$resourcePath = str_replace("{format}", "json", $resourcePath);
@@ -264,7 +264,7 @@ class PetApi {
*/
public function findPetsByTags($tags) {
// parse inputs
$resourcePath = "/pet/findByTags";
$resourcePath = str_replace("{format}", "json", $resourcePath);
@@ -333,13 +333,11 @@ class PetApi {
* @throws \Swagger\Client\ApiException on non-2xx response
*/
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);
@@ -419,13 +417,11 @@ class PetApi {
* @throws \Swagger\Client\ApiException on non-2xx response
*/
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);
@@ -493,13 +489,11 @@ class PetApi {
* @throws \Swagger\Client\ApiException on non-2xx response
*/
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);
@@ -565,13 +559,11 @@ class PetApi {
* @throws \Swagger\Client\ApiException on non-2xx response
*/
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);

View File

@@ -71,7 +71,7 @@ class StoreApi {
*/
public function getInventory() {
// parse inputs
$resourcePath = "/store/inventory";
$resourcePath = str_replace("{format}", "json", $resourcePath);
@@ -142,7 +142,7 @@ class StoreApi {
*/
public function placeOrder($body) {
// parse inputs
$resourcePath = "/store/order";
$resourcePath = str_replace("{format}", "json", $resourcePath);
@@ -209,13 +209,11 @@ class StoreApi {
* @throws \Swagger\Client\ApiException on non-2xx response
*/
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);
@@ -283,13 +281,11 @@ class StoreApi {
* @throws \Swagger\Client\ApiException on non-2xx response
*/
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);

View File

@@ -72,7 +72,7 @@ class UserApi {
*/
public function createUser($body) {
// parse inputs
$resourcePath = "/user";
$resourcePath = str_replace("{format}", "json", $resourcePath);
@@ -130,7 +130,7 @@ class UserApi {
*/
public function createUsersWithArrayInput($body) {
// parse inputs
$resourcePath = "/user/createWithArray";
$resourcePath = str_replace("{format}", "json", $resourcePath);
@@ -188,7 +188,7 @@ class UserApi {
*/
public function createUsersWithListInput($body) {
// parse inputs
$resourcePath = "/user/createWithList";
$resourcePath = str_replace("{format}", "json", $resourcePath);
@@ -247,7 +247,7 @@ class UserApi {
*/
public function loginUser($username, $password) {
// parse inputs
$resourcePath = "/user/login";
$resourcePath = str_replace("{format}", "json", $resourcePath);
@@ -316,7 +316,7 @@ class UserApi {
*/
public function logoutUser() {
// parse inputs
$resourcePath = "/user/logout";
$resourcePath = str_replace("{format}", "json", $resourcePath);
@@ -369,13 +369,11 @@ class UserApi {
* @throws \Swagger\Client\ApiException on non-2xx response
*/
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);
@@ -444,13 +442,11 @@ class UserApi {
* @throws \Swagger\Client\ApiException on non-2xx response
*/
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);
@@ -512,13 +508,11 @@ class UserApi {
* @throws \Swagger\Client\ApiException on non-2xx response
*/
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);

View File

@@ -79,6 +79,7 @@ class Category implements ArrayAccess {
* @return $this
*/
public function setId($id) {
$this->id = $id;
return $this;
}
@@ -97,6 +98,7 @@ class Category implements ArrayAccess {
* @return $this
*/
public function setName($name) {
$this->name = $name;
return $this;
}

View File

@@ -111,6 +111,7 @@ class Order implements ArrayAccess {
* @return $this
*/
public function setId($id) {
$this->id = $id;
return $this;
}
@@ -129,6 +130,7 @@ class Order implements ArrayAccess {
* @return $this
*/
public function setPetId($pet_id) {
$this->pet_id = $pet_id;
return $this;
}
@@ -147,6 +149,7 @@ class Order implements ArrayAccess {
* @return $this
*/
public function setQuantity($quantity) {
$this->quantity = $quantity;
return $this;
}
@@ -165,6 +168,7 @@ class Order implements ArrayAccess {
* @return $this
*/
public function setShipDate($ship_date) {
$this->ship_date = $ship_date;
return $this;
}
@@ -183,6 +187,10 @@ class Order implements ArrayAccess {
* @return $this
*/
public function setStatus($status) {
$allowed_values = array("placed", "approved", "delivered");
if (!in_array($status, $allowed_values)) {
throw new \InvalidArgumentException("Invalid value for 'status', must be one of 'placed', 'approved', 'delivered'");
}
$this->status = $status;
return $this;
}
@@ -201,6 +209,7 @@ class Order implements ArrayAccess {
* @return $this
*/
public function setComplete($complete) {
$this->complete = $complete;
return $this;
}

View File

@@ -111,6 +111,7 @@ class Pet implements ArrayAccess {
* @return $this
*/
public function setId($id) {
$this->id = $id;
return $this;
}
@@ -129,6 +130,7 @@ class Pet implements ArrayAccess {
* @return $this
*/
public function setCategory($category) {
$this->category = $category;
return $this;
}
@@ -147,6 +149,7 @@ class Pet implements ArrayAccess {
* @return $this
*/
public function setName($name) {
$this->name = $name;
return $this;
}
@@ -165,6 +168,7 @@ class Pet implements ArrayAccess {
* @return $this
*/
public function setPhotoUrls($photo_urls) {
$this->photo_urls = $photo_urls;
return $this;
}
@@ -183,6 +187,7 @@ class Pet implements ArrayAccess {
* @return $this
*/
public function setTags($tags) {
$this->tags = $tags;
return $this;
}
@@ -201,6 +206,10 @@ class Pet implements ArrayAccess {
* @return $this
*/
public function setStatus($status) {
$allowed_values = array("available", "pending", "sold");
if (!in_array($status, $allowed_values)) {
throw new \InvalidArgumentException("Invalid value for 'status', must be one of 'available', 'pending', 'sold'");
}
$this->status = $status;
return $this;
}

View File

@@ -79,6 +79,7 @@ class Tag implements ArrayAccess {
* @return $this
*/
public function setId($id) {
$this->id = $id;
return $this;
}
@@ -97,6 +98,7 @@ class Tag implements ArrayAccess {
* @return $this
*/
public function setName($name) {
$this->name = $name;
return $this;
}

View File

@@ -127,6 +127,7 @@ class User implements ArrayAccess {
* @return $this
*/
public function setId($id) {
$this->id = $id;
return $this;
}
@@ -145,6 +146,7 @@ class User implements ArrayAccess {
* @return $this
*/
public function setUsername($username) {
$this->username = $username;
return $this;
}
@@ -163,6 +165,7 @@ class User implements ArrayAccess {
* @return $this
*/
public function setFirstName($first_name) {
$this->first_name = $first_name;
return $this;
}
@@ -181,6 +184,7 @@ class User implements ArrayAccess {
* @return $this
*/
public function setLastName($last_name) {
$this->last_name = $last_name;
return $this;
}
@@ -199,6 +203,7 @@ class User implements ArrayAccess {
* @return $this
*/
public function setEmail($email) {
$this->email = $email;
return $this;
}
@@ -217,6 +222,7 @@ class User implements ArrayAccess {
* @return $this
*/
public function setPassword($password) {
$this->password = $password;
return $this;
}
@@ -235,6 +241,7 @@ class User implements ArrayAccess {
* @return $this
*/
public function setPhone($phone) {
$this->phone = $phone;
return $this;
}
@@ -253,6 +260,7 @@ class User implements ArrayAccess {
* @return $this
*/
public function setUserStatus($user_status) {
$this->user_status = $user_status;
return $this;
}

View File

@@ -0,0 +1,38 @@
<?php
require_once('autoload.php');
class OrderApiTest extends \PHPUnit_Framework_TestCase
{
// add a new pet (id 10005) to ensure the pet object is available for all the tests
public static function setUpBeforeClass() {
// for error reporting (need to run with php5.3 to get no warning)
//ini_set('display_errors', 1);
//error_reporting(~0);
}
// test get inventory
public function testOrder()
{
// initialize the API client
$order = new Swagger\Client\Model\Order();
$order->setStatus("placed");
$this->assertSame("placed", $order->getStatus());
}
/**
* @expectedException InvalidArgumentException
*/
public function testOrderException()
{
// initialize the API client
$order = new Swagger\Client\Model\Order();
$order->setStatus("invalid_value");
}
}
?>