add validation to model

This commit is contained in:
abcsun
2016-05-05 11:41:14 +08:00
parent f4ef2b0325
commit 22ea2d87e0
17 changed files with 987 additions and 60 deletions

View File

@@ -135,6 +135,51 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
} }
} }
/**
* show all the invalid properties with reasons.
*
* @return array invalid properties with reasons
*/
public function list_invalid_properties()
{
$invalid_properties = array();
{{#vars}}{{#required}}
if ($this->{{name}} === null) {
$invalid_properties[] = "'${{name}}' can't be null";
}{{/required}}
{{#isEnum}}$allowed_values = array({{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}});
if (!in_array($this->{{name}}, $allowed_values))) {
$invalid_properties[] = "invalid value for '${{name}}', must be one of #{allowed_values}.";
}{{/isEnum}}
{{#hasValidation}}
{{#maxLength}}
if (strlen($this->{{name}}) > {{maxLength}}) {
$invalid_properties[] = "invalid value for '${{name}}', the character length must be smaller than or equal to {{{maxLength}}}.";
}
{{/maxLength}}
{{#minLength}}
if (strlen($this->{{name}}) < {{minLength}}) {
$invalid_properties[] = "invalid value for '${{name}}', the character length must be bigger than or equal to {{{minLength}}}.";
}
{{/minLength}}
{{#maximum}}
if ($this->{{name}} > {{maximum}}) {
$invalid_properties[] = "invalid value for '${{name}}', must be smaller than or equal to {{maximum}}.";
}
{{/maximum}}
{{#minimum}}
if ($this->{{name}} < {{minimum}}) {
$invalid_properties[] = "invalid value for '${{name}}', must be bigger than or equal to {{minimum}}.";
}
{{/minimum}}
{{#pattern}}
if (!preg_match("{{pattern}}", $this->{{name}})) {
$invalid_properties[] = "invalid value for '${{name}}', must be conform to the pattern {{pattern}}.";
}
{{/pattern}}{{/hasValidation}}{{/vars}}
return $invalid_properties;
}
/** /**
* validate all the parameters in the model * validate all the parameters in the model
* return true if all passed * return true if all passed
@@ -143,12 +188,14 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
*/ */
public function valid() public function valid()
{ {
{{#vars}} {{#vars}}{{#required}}
{{#required}}
if ($this->{{name}} === null) { if ($this->{{name}} === null) {
return false; return false;
} }{{/required}}
{{/required}} {{#isEnum}}$allowed_values = array({{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}});
if (!in_array($this->{{name}}, $allowed_values))) {
return false;
}{{/isEnum}}
{{#hasValidation}} {{#hasValidation}}
{{#maxLength}} {{#maxLength}}
if (strlen($this->{{name}}) > {{maxLength}}) { if (strlen($this->{{name}}) > {{maxLength}}) {
@@ -174,9 +221,7 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
if (!preg_match("{{pattern}}", $this->{{name}})) { if (!preg_match("{{pattern}}", $this->{{name}})) {
return false; return false;
} }
{{/pattern}} {{/pattern}}{{/hasValidation}}{{/vars}}
{{/hasValidation}}
{{/vars}}
return true; return true;
} }
@@ -224,10 +269,9 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
{{/minimum}} {{/minimum}}
{{#pattern}} {{#pattern}}
if (!preg_match("{{pattern}}", ${{name}})) { if (!preg_match("{{pattern}}", ${{name}})) {
throw new \InvalidArgumentException('invalid value for ${{name}} when calling {{classname}}.{{operationId}}, must conform to the pattern {{pattern}}.'); throw new \InvalidArgumentException('invalid value for ${{name}} when calling {{classname}}.{{operationId}}, must be conform to the pattern {{pattern}}.');
} }
{{/pattern}} {{/pattern}}{{/hasValidation}}
{{/hasValidation}}
$this->{{name}} = ${{name}}; $this->{{name}} = ${{name}};
return $this; return $this;
} }

View File

@@ -5,7 +5,7 @@ This PHP package is automatically generated by the [Swagger Codegen](https://git
- API version: 1.0.0 - API version: 1.0.0
- Package version: 1.0.0 - Package version: 1.0.0
- Build date: 2016-04-29T03:01:58.276Z - Build date: 2016-05-05T03:40:26.342Z
- Build package: class io.swagger.codegen.languages.PhpClientCodegen - Build package: class io.swagger.codegen.languages.PhpClientCodegen
## Requirements ## Requirements

View File

@@ -198,7 +198,7 @@ class FakeApi
if (strlen($password) > 64) { if (strlen($password) > 64) {
throw new \InvalidArgumentException('invalid length for "$password" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 64.'); throw new \InvalidArgumentException('invalid length for "$password" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 64.');
} }
if (strlen($password) > 10) { if (strlen($password) < 10) {
throw new \InvalidArgumentException('invalid length for "$password" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 10.'); throw new \InvalidArgumentException('invalid length for "$password" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 10.');
} }

View File

@@ -118,9 +118,47 @@ class Animal implements ArrayAccess
$this->{$discrimintor} = static::$swaggerModelName; $this->{$discrimintor} = static::$swaggerModelName;
if ($data != null) { if ($data != null) {
$this->class_name = $data["class_name"]; if (isset($data["class_name"])) {
$this->class_name = $data["class_name"];
}
} }
} }
/**
* show all the invalid properties with reasons.
*
* @return array invalid properties with reasons
*/
public function list_invalid_properties()
{
$invalid_properties = array();
if ($this->class_name === null) {
$invalid_properties[] = "'$class_name' can't be null";
}
return $invalid_properties;
}
/**
* validate all the parameters in the model
* return true if all passed
*
* @return bool [description]
*/
public function valid()
{
if ($this->class_name === null) {
return false;
}
return true;
}
/** /**
* Gets class_name * Gets class_name
* @return string * @return string
@@ -138,6 +176,7 @@ class Animal implements ArrayAccess
public function setClassName($class_name) public function setClassName($class_name)
{ {
$this->class_name = $class_name; $this->class_name = $class_name;
return $this; return $this;
} }

View File

@@ -133,11 +133,55 @@ class ApiResponse implements ArrayAccess
if ($data != null) { if ($data != null) {
$this->code = $data["code"]; if (isset($data["code"])) {
$this->type = $data["type"]; $this->code = $data["code"];
$this->message = $data["message"]; }
if (isset($data["type"])) {
$this->type = $data["type"];
}
if (isset($data["message"])) {
$this->message = $data["message"];
}
} }
} }
/**
* show all the invalid properties with reasons.
*
* @return array invalid properties with reasons
*/
public function list_invalid_properties()
{
$invalid_properties = array();
return $invalid_properties;
}
/**
* validate all the parameters in the model
* return true if all passed
*
* @return bool [description]
*/
public function valid()
{
return true;
}
/** /**
* Gets code * Gets code
* @return int * @return int
@@ -155,6 +199,7 @@ class ApiResponse implements ArrayAccess
public function setCode($code) public function setCode($code)
{ {
$this->code = $code; $this->code = $code;
return $this; return $this;
} }
@@ -175,6 +220,7 @@ class ApiResponse implements ArrayAccess
public function setType($type) public function setType($type)
{ {
$this->type = $type; $this->type = $type;
return $this; return $this;
} }
@@ -195,6 +241,7 @@ class ApiResponse implements ArrayAccess
public function setMessage($message) public function setMessage($message)
{ {
$this->message = $message; $this->message = $message;
return $this; return $this;
} }

View File

@@ -115,9 +115,41 @@ class Cat extends Animal implements ArrayAccess
parent::__construct($data); parent::__construct($data);
if ($data != null) { if ($data != null) {
$this->declawed = $data["declawed"]; if (isset($data["declawed"])) {
$this->declawed = $data["declawed"];
}
} }
} }
/**
* show all the invalid properties with reasons.
*
* @return array invalid properties with reasons
*/
public function list_invalid_properties()
{
$invalid_properties = array();
return $invalid_properties;
}
/**
* validate all the parameters in the model
* return true if all passed
*
* @return bool [description]
*/
public function valid()
{
return true;
}
/** /**
* Gets declawed * Gets declawed
* @return bool * @return bool
@@ -135,6 +167,7 @@ class Cat extends Animal implements ArrayAccess
public function setDeclawed($declawed) public function setDeclawed($declawed)
{ {
$this->declawed = $declawed; $this->declawed = $declawed;
return $this; return $this;
} }

View File

@@ -124,10 +124,48 @@ class Category implements ArrayAccess
if ($data != null) { if ($data != null) {
$this->id = $data["id"]; if (isset($data["id"])) {
$this->name = $data["name"]; $this->id = $data["id"];
}
if (isset($data["name"])) {
$this->name = $data["name"];
}
} }
} }
/**
* show all the invalid properties with reasons.
*
* @return array invalid properties with reasons
*/
public function list_invalid_properties()
{
$invalid_properties = array();
return $invalid_properties;
}
/**
* validate all the parameters in the model
* return true if all passed
*
* @return bool [description]
*/
public function valid()
{
return true;
}
/** /**
* Gets id * Gets id
* @return int * @return int
@@ -145,6 +183,7 @@ class Category implements ArrayAccess
public function setId($id) public function setId($id)
{ {
$this->id = $id; $this->id = $id;
return $this; return $this;
} }
@@ -165,6 +204,7 @@ class Category implements ArrayAccess
public function setName($name) public function setName($name)
{ {
$this->name = $name; $this->name = $name;
return $this; return $this;
} }

View File

@@ -115,9 +115,41 @@ class Dog extends Animal implements ArrayAccess
parent::__construct($data); parent::__construct($data);
if ($data != null) { if ($data != null) {
$this->breed = $data["breed"]; if (isset($data["breed"])) {
$this->breed = $data["breed"];
}
} }
} }
/**
* show all the invalid properties with reasons.
*
* @return array invalid properties with reasons
*/
public function list_invalid_properties()
{
$invalid_properties = array();
return $invalid_properties;
}
/**
* validate all the parameters in the model
* return true if all passed
*
* @return bool [description]
*/
public function valid()
{
return true;
}
/** /**
* Gets breed * Gets breed
* @return string * @return string
@@ -135,6 +167,7 @@ class Dog extends Animal implements ArrayAccess
public function setBreed($breed) public function setBreed($breed)
{ {
$this->breed = $breed; $this->breed = $breed;
return $this; return $this;
} }

View File

@@ -214,20 +214,220 @@ class FormatTest implements ArrayAccess
if ($data != null) { if ($data != null) {
$this->integer = $data["integer"]; if (isset($data["integer"])) {
$this->int32 = $data["int32"]; $this->integer = $data["integer"];
$this->int64 = $data["int64"]; }
$this->number = $data["number"]; if (isset($data["int32"])) {
$this->float = $data["float"]; $this->int32 = $data["int32"];
$this->double = $data["double"]; }
$this->string = $data["string"]; if (isset($data["int64"])) {
$this->byte = $data["byte"]; $this->int64 = $data["int64"];
$this->binary = $data["binary"]; }
$this->date = $data["date"]; if (isset($data["number"])) {
$this->date_time = $data["date_time"]; $this->number = $data["number"];
$this->password = $data["password"]; }
if (isset($data["float"])) {
$this->float = $data["float"];
}
if (isset($data["double"])) {
$this->double = $data["double"];
}
if (isset($data["string"])) {
$this->string = $data["string"];
}
if (isset($data["byte"])) {
$this->byte = $data["byte"];
}
if (isset($data["binary"])) {
$this->binary = $data["binary"];
}
if (isset($data["date"])) {
$this->date = $data["date"];
}
if (isset($data["date_time"])) {
$this->date_time = $data["date_time"];
}
if (isset($data["password"])) {
$this->password = $data["password"];
}
} }
} }
/**
* show all the invalid properties with reasons.
*
* @return array invalid properties with reasons
*/
public function list_invalid_properties()
{
$invalid_properties = array();
if ($this->integer > 100.0) {
$invalid_properties[] = "invalid value for '$integer', must be smaller than or equal to 100.0.";
}
if ($this->integer < 10.0) {
$invalid_properties[] = "invalid value for '$integer', must be bigger than or equal to 10.0.";
}
if ($this->int32 > 200.0) {
$invalid_properties[] = "invalid value for '$int32', must be smaller than or equal to 200.0.";
}
if ($this->int32 < 20.0) {
$invalid_properties[] = "invalid value for '$int32', must be bigger than or equal to 20.0.";
}
if ($this->number === null) {
$invalid_properties[] = "'$number' can't be null";
}
if ($this->number > 543.2) {
$invalid_properties[] = "invalid value for '$number', must be smaller than or equal to 543.2.";
}
if ($this->number < 32.1) {
$invalid_properties[] = "invalid value for '$number', must be bigger than or equal to 32.1.";
}
if ($this->float > 987.6) {
$invalid_properties[] = "invalid value for '$float', must be smaller than or equal to 987.6.";
}
if ($this->float < 54.3) {
$invalid_properties[] = "invalid value for '$float', must be bigger than or equal to 54.3.";
}
if ($this->double > 123.4) {
$invalid_properties[] = "invalid value for '$double', must be smaller than or equal to 123.4.";
}
if ($this->double < 67.8) {
$invalid_properties[] = "invalid value for '$double', must be bigger than or equal to 67.8.";
}
if (!preg_match("/[a-z]/i", $this->string)) {
$invalid_properties[] = "invalid value for '$string', must be conform to the pattern /[a-z]/i.";
}
if ($this->byte === null) {
$invalid_properties[] = "'$byte' can't be null";
}
if ($this->date === null) {
$invalid_properties[] = "'$date' can't be null";
}
if ($this->password === null) {
$invalid_properties[] = "'$password' can't be null";
}
if (strlen($this->password) > 64) {
$invalid_properties[] = "invalid value for '$password', the character length must be smaller than or equal to 64.";
}
if (strlen($this->password) < 10) {
$invalid_properties[] = "invalid value for '$password', the character length must be bigger than or equal to 10.";
}
return $invalid_properties;
}
/**
* validate all the parameters in the model
* return true if all passed
*
* @return bool [description]
*/
public function valid()
{
if ($this->integer > 100.0) {
return false;
}
if ($this->integer < 10.0) {
return false;
}
if ($this->int32 > 200.0) {
return false;
}
if ($this->int32 < 20.0) {
return false;
}
if ($this->number === null) {
return false;
}
if ($this->number > 543.2) {
return false;
}
if ($this->number < 32.1) {
return false;
}
if ($this->float > 987.6) {
return false;
}
if ($this->float < 54.3) {
return false;
}
if ($this->double > 123.4) {
return false;
}
if ($this->double < 67.8) {
return false;
}
if (!preg_match("/[a-z]/i", $this->string)) {
return false;
}
if ($this->byte === null) {
return false;
}
if ($this->date === null) {
return false;
}
if ($this->password === null) {
return false;
}
if (strlen($this->password) > 64) {
return false;
}
if (strlen($this->password) < 10) {
return false;
}
return true;
}
/** /**
* Gets integer * Gets integer
* @return int * @return int
@@ -245,6 +445,14 @@ class FormatTest implements ArrayAccess
public function setInteger($integer) public function setInteger($integer)
{ {
if ($integer > 100.0) {
throw new \InvalidArgumentException('invalid value for $integer when calling FormatTest., must be smaller than or equal to 100.0.');
}
if ($integer < 10.0) {
throw new \InvalidArgumentException('invalid value for $integer when calling FormatTest., must be bigger than or equal to 10.0.');
}
$this->integer = $integer; $this->integer = $integer;
return $this; return $this;
} }
@@ -265,6 +473,14 @@ class FormatTest implements ArrayAccess
public function setInt32($int32) public function setInt32($int32)
{ {
if ($int32 > 200.0) {
throw new \InvalidArgumentException('invalid value for $int32 when calling FormatTest., must be smaller than or equal to 200.0.');
}
if ($int32 < 20.0) {
throw new \InvalidArgumentException('invalid value for $int32 when calling FormatTest., must be bigger than or equal to 20.0.');
}
$this->int32 = $int32; $this->int32 = $int32;
return $this; return $this;
} }
@@ -285,6 +501,7 @@ class FormatTest implements ArrayAccess
public function setInt64($int64) public function setInt64($int64)
{ {
$this->int64 = $int64; $this->int64 = $int64;
return $this; return $this;
} }
@@ -305,6 +522,14 @@ class FormatTest implements ArrayAccess
public function setNumber($number) public function setNumber($number)
{ {
if ($number > 543.2) {
throw new \InvalidArgumentException('invalid value for $number when calling FormatTest., must be smaller than or equal to 543.2.');
}
if ($number < 32.1) {
throw new \InvalidArgumentException('invalid value for $number when calling FormatTest., must be bigger than or equal to 32.1.');
}
$this->number = $number; $this->number = $number;
return $this; return $this;
} }
@@ -325,6 +550,14 @@ class FormatTest implements ArrayAccess
public function setFloat($float) public function setFloat($float)
{ {
if ($float > 987.6) {
throw new \InvalidArgumentException('invalid value for $float when calling FormatTest., must be smaller than or equal to 987.6.');
}
if ($float < 54.3) {
throw new \InvalidArgumentException('invalid value for $float when calling FormatTest., must be bigger than or equal to 54.3.');
}
$this->float = $float; $this->float = $float;
return $this; return $this;
} }
@@ -345,6 +578,14 @@ class FormatTest implements ArrayAccess
public function setDouble($double) public function setDouble($double)
{ {
if ($double > 123.4) {
throw new \InvalidArgumentException('invalid value for $double when calling FormatTest., must be smaller than or equal to 123.4.');
}
if ($double < 67.8) {
throw new \InvalidArgumentException('invalid value for $double when calling FormatTest., must be bigger than or equal to 67.8.');
}
$this->double = $double; $this->double = $double;
return $this; return $this;
} }
@@ -365,6 +606,11 @@ class FormatTest implements ArrayAccess
public function setString($string) public function setString($string)
{ {
if (!preg_match("/[a-z]/i", $string)) {
throw new \InvalidArgumentException('invalid value for $string when calling FormatTest., must be conform to the pattern /[a-z]/i.');
}
$this->string = $string; $this->string = $string;
return $this; return $this;
} }
@@ -385,6 +631,7 @@ class FormatTest implements ArrayAccess
public function setByte($byte) public function setByte($byte)
{ {
$this->byte = $byte; $this->byte = $byte;
return $this; return $this;
} }
@@ -405,6 +652,7 @@ class FormatTest implements ArrayAccess
public function setBinary($binary) public function setBinary($binary)
{ {
$this->binary = $binary; $this->binary = $binary;
return $this; return $this;
} }
@@ -425,6 +673,7 @@ class FormatTest implements ArrayAccess
public function setDate($date) public function setDate($date)
{ {
$this->date = $date; $this->date = $date;
return $this; return $this;
} }
@@ -445,6 +694,7 @@ class FormatTest implements ArrayAccess
public function setDateTime($date_time) public function setDateTime($date_time)
{ {
$this->date_time = $date_time; $this->date_time = $date_time;
return $this; return $this;
} }
@@ -465,6 +715,13 @@ class FormatTest implements ArrayAccess
public function setPassword($password) public function setPassword($password)
{ {
if (strlen($password) > 64) {
throw new \InvalidArgumentException('invalid length for $password when calling FormatTest., must be smaller than or equal to 64.');
}
if (strlen($password) < 10) {
throw new \InvalidArgumentException('invalid length for $password when calling FormatTest., must be bigger than or equal to 10.');
}
$this->password = $password; $this->password = $password;
return $this; return $this;
} }

View File

@@ -115,9 +115,41 @@ class Model200Response implements ArrayAccess
if ($data != null) { if ($data != null) {
$this->name = $data["name"]; if (isset($data["name"])) {
$this->name = $data["name"];
}
} }
} }
/**
* show all the invalid properties with reasons.
*
* @return array invalid properties with reasons
*/
public function list_invalid_properties()
{
$invalid_properties = array();
return $invalid_properties;
}
/**
* validate all the parameters in the model
* return true if all passed
*
* @return bool [description]
*/
public function valid()
{
return true;
}
/** /**
* Gets name * Gets name
* @return int * @return int
@@ -135,6 +167,7 @@ class Model200Response implements ArrayAccess
public function setName($name) public function setName($name)
{ {
$this->name = $name; $this->name = $name;
return $this; return $this;
} }

View File

@@ -115,9 +115,41 @@ class ModelReturn implements ArrayAccess
if ($data != null) { if ($data != null) {
$this->return = $data["return"]; if (isset($data["return"])) {
$this->return = $data["return"];
}
} }
} }
/**
* show all the invalid properties with reasons.
*
* @return array invalid properties with reasons
*/
public function list_invalid_properties()
{
$invalid_properties = array();
return $invalid_properties;
}
/**
* validate all the parameters in the model
* return true if all passed
*
* @return bool [description]
*/
public function valid()
{
return true;
}
/** /**
* Gets return * Gets return
* @return int * @return int
@@ -135,6 +167,7 @@ class ModelReturn implements ArrayAccess
public function setReturn($return) public function setReturn($return)
{ {
$this->return = $return; $this->return = $return;
return $this; return $this;
} }

View File

@@ -133,11 +133,61 @@ class Name implements ArrayAccess
if ($data != null) { if ($data != null) {
$this->name = $data["name"]; if (isset($data["name"])) {
$this->snake_case = $data["snake_case"]; $this->name = $data["name"];
$this->property = $data["property"]; }
if (isset($data["snake_case"])) {
$this->snake_case = $data["snake_case"];
}
if (isset($data["property"])) {
$this->property = $data["property"];
}
} }
} }
/**
* show all the invalid properties with reasons.
*
* @return array invalid properties with reasons
*/
public function list_invalid_properties()
{
$invalid_properties = array();
if ($this->name === null) {
$invalid_properties[] = "'$name' can't be null";
}
return $invalid_properties;
}
/**
* validate all the parameters in the model
* return true if all passed
*
* @return bool [description]
*/
public function valid()
{
if ($this->name === null) {
return false;
}
return true;
}
/** /**
* Gets name * Gets name
* @return int * @return int
@@ -155,6 +205,7 @@ class Name implements ArrayAccess
public function setName($name) public function setName($name)
{ {
$this->name = $name; $this->name = $name;
return $this; return $this;
} }
@@ -175,6 +226,7 @@ class Name implements ArrayAccess
public function setSnakeCase($snake_case) public function setSnakeCase($snake_case)
{ {
$this->snake_case = $snake_case; $this->snake_case = $snake_case;
return $this; return $this;
} }
@@ -195,6 +247,7 @@ class Name implements ArrayAccess
public function setProperty($property) public function setProperty($property)
{ {
$this->property = $property; $this->property = $property;
return $this; return $this;
} }

View File

@@ -160,14 +160,82 @@ class Order implements ArrayAccess
if ($data != null) { if ($data != null) {
$this->id = $data["id"]; if (isset($data["id"])) {
$this->pet_id = $data["pet_id"]; $this->id = $data["id"];
$this->quantity = $data["quantity"]; }
$this->ship_date = $data["ship_date"]; if (isset($data["pet_id"])) {
$this->status = $data["status"]; $this->pet_id = $data["pet_id"];
$this->complete = $data["complete"]; }
if (isset($data["quantity"])) {
$this->quantity = $data["quantity"];
}
if (isset($data["ship_date"])) {
$this->ship_date = $data["ship_date"];
}
if (isset($data["status"])) {
$this->status = $data["status"];
}
if (isset($data["complete"])) {
$this->complete = $data["complete"];
}
} }
} }
/**
* show all the invalid properties with reasons.
*
* @return array invalid properties with reasons
*/
public function list_invalid_properties()
{
$invalid_properties = array();
$allowed_values = array("placed", "approved", "delivered");
if (!in_array($this->status, $allowed_values))) {
$invalid_properties[] = "invalid value for '$status', must be one of #{allowed_values}.";
}
return $invalid_properties;
}
/**
* validate all the parameters in the model
* return true if all passed
*
* @return bool [description]
*/
public function valid()
{
$allowed_values = array("placed", "approved", "delivered");
if (!in_array($this->status, $allowed_values))) {
return false;
}
return true;
}
/** /**
* Gets id * Gets id
* @return int * @return int
@@ -185,6 +253,7 @@ class Order implements ArrayAccess
public function setId($id) public function setId($id)
{ {
$this->id = $id; $this->id = $id;
return $this; return $this;
} }
@@ -205,6 +274,7 @@ class Order implements ArrayAccess
public function setPetId($pet_id) public function setPetId($pet_id)
{ {
$this->pet_id = $pet_id; $this->pet_id = $pet_id;
return $this; return $this;
} }
@@ -225,6 +295,7 @@ class Order implements ArrayAccess
public function setQuantity($quantity) public function setQuantity($quantity)
{ {
$this->quantity = $quantity; $this->quantity = $quantity;
return $this; return $this;
} }
@@ -245,6 +316,7 @@ class Order implements ArrayAccess
public function setShipDate($ship_date) public function setShipDate($ship_date)
{ {
$this->ship_date = $ship_date; $this->ship_date = $ship_date;
return $this; return $this;
} }
@@ -268,6 +340,7 @@ class Order implements ArrayAccess
if (!in_array($status, $allowed_values)) { if (!in_array($status, $allowed_values)) {
throw new \InvalidArgumentException("Invalid value for 'status', must be one of 'placed', 'approved', 'delivered'"); throw new \InvalidArgumentException("Invalid value for 'status', must be one of 'placed', 'approved', 'delivered'");
} }
$this->status = $status; $this->status = $status;
return $this; return $this;
} }
@@ -288,6 +361,7 @@ class Order implements ArrayAccess
public function setComplete($complete) public function setComplete($complete)
{ {
$this->complete = $complete; $this->complete = $complete;
return $this; return $this;
} }

View File

@@ -160,14 +160,94 @@ class Pet implements ArrayAccess
if ($data != null) { if ($data != null) {
$this->id = $data["id"]; if (isset($data["id"])) {
$this->category = $data["category"]; $this->id = $data["id"];
$this->name = $data["name"]; }
$this->photo_urls = $data["photo_urls"]; if (isset($data["category"])) {
$this->tags = $data["tags"]; $this->category = $data["category"];
$this->status = $data["status"]; }
if (isset($data["name"])) {
$this->name = $data["name"];
}
if (isset($data["photo_urls"])) {
$this->photo_urls = $data["photo_urls"];
}
if (isset($data["tags"])) {
$this->tags = $data["tags"];
}
if (isset($data["status"])) {
$this->status = $data["status"];
}
} }
} }
/**
* show all the invalid properties with reasons.
*
* @return array invalid properties with reasons
*/
public function list_invalid_properties()
{
$invalid_properties = array();
if ($this->name === null) {
$invalid_properties[] = "'$name' can't be null";
}
if ($this->photo_urls === null) {
$invalid_properties[] = "'$photo_urls' can't be null";
}
$allowed_values = array("available", "pending", "sold");
if (!in_array($this->status, $allowed_values))) {
$invalid_properties[] = "invalid value for '$status', must be one of #{allowed_values}.";
}
return $invalid_properties;
}
/**
* validate all the parameters in the model
* return true if all passed
*
* @return bool [description]
*/
public function valid()
{
if ($this->name === null) {
return false;
}
if ($this->photo_urls === null) {
return false;
}
$allowed_values = array("available", "pending", "sold");
if (!in_array($this->status, $allowed_values))) {
return false;
}
return true;
}
/** /**
* Gets id * Gets id
* @return int * @return int
@@ -185,6 +265,7 @@ class Pet implements ArrayAccess
public function setId($id) public function setId($id)
{ {
$this->id = $id; $this->id = $id;
return $this; return $this;
} }
@@ -205,6 +286,7 @@ class Pet implements ArrayAccess
public function setCategory($category) public function setCategory($category)
{ {
$this->category = $category; $this->category = $category;
return $this; return $this;
} }
@@ -225,6 +307,7 @@ class Pet implements ArrayAccess
public function setName($name) public function setName($name)
{ {
$this->name = $name; $this->name = $name;
return $this; return $this;
} }
@@ -245,6 +328,7 @@ class Pet implements ArrayAccess
public function setPhotoUrls($photo_urls) public function setPhotoUrls($photo_urls)
{ {
$this->photo_urls = $photo_urls; $this->photo_urls = $photo_urls;
return $this; return $this;
} }
@@ -265,6 +349,7 @@ class Pet implements ArrayAccess
public function setTags($tags) public function setTags($tags)
{ {
$this->tags = $tags; $this->tags = $tags;
return $this; return $this;
} }
@@ -288,6 +373,7 @@ class Pet implements ArrayAccess
if (!in_array($status, $allowed_values)) { if (!in_array($status, $allowed_values)) {
throw new \InvalidArgumentException("Invalid value for 'status', must be one of 'available', 'pending', 'sold'"); throw new \InvalidArgumentException("Invalid value for 'status', must be one of 'available', 'pending', 'sold'");
} }
$this->status = $status; $this->status = $status;
return $this; return $this;
} }

View File

@@ -115,9 +115,41 @@ class SpecialModelName implements ArrayAccess
if ($data != null) { if ($data != null) {
$this->special_property_name = $data["special_property_name"]; if (isset($data["special_property_name"])) {
$this->special_property_name = $data["special_property_name"];
}
} }
} }
/**
* show all the invalid properties with reasons.
*
* @return array invalid properties with reasons
*/
public function list_invalid_properties()
{
$invalid_properties = array();
return $invalid_properties;
}
/**
* validate all the parameters in the model
* return true if all passed
*
* @return bool [description]
*/
public function valid()
{
return true;
}
/** /**
* Gets special_property_name * Gets special_property_name
* @return int * @return int
@@ -135,6 +167,7 @@ class SpecialModelName implements ArrayAccess
public function setSpecialPropertyName($special_property_name) public function setSpecialPropertyName($special_property_name)
{ {
$this->special_property_name = $special_property_name; $this->special_property_name = $special_property_name;
return $this; return $this;
} }

View File

@@ -124,10 +124,48 @@ class Tag implements ArrayAccess
if ($data != null) { if ($data != null) {
$this->id = $data["id"]; if (isset($data["id"])) {
$this->name = $data["name"]; $this->id = $data["id"];
}
if (isset($data["name"])) {
$this->name = $data["name"];
}
} }
} }
/**
* show all the invalid properties with reasons.
*
* @return array invalid properties with reasons
*/
public function list_invalid_properties()
{
$invalid_properties = array();
return $invalid_properties;
}
/**
* validate all the parameters in the model
* return true if all passed
*
* @return bool [description]
*/
public function valid()
{
return true;
}
/** /**
* Gets id * Gets id
* @return int * @return int
@@ -145,6 +183,7 @@ class Tag implements ArrayAccess
public function setId($id) public function setId($id)
{ {
$this->id = $id; $this->id = $id;
return $this; return $this;
} }
@@ -165,6 +204,7 @@ class Tag implements ArrayAccess
public function setName($name) public function setName($name)
{ {
$this->name = $name; $this->name = $name;
return $this; return $this;
} }

View File

@@ -178,16 +178,90 @@ class User implements ArrayAccess
if ($data != null) { if ($data != null) {
$this->id = $data["id"]; if (isset($data["id"])) {
$this->username = $data["username"]; $this->id = $data["id"];
$this->first_name = $data["first_name"]; }
$this->last_name = $data["last_name"]; if (isset($data["username"])) {
$this->email = $data["email"]; $this->username = $data["username"];
$this->password = $data["password"]; }
$this->phone = $data["phone"]; if (isset($data["first_name"])) {
$this->user_status = $data["user_status"]; $this->first_name = $data["first_name"];
}
if (isset($data["last_name"])) {
$this->last_name = $data["last_name"];
}
if (isset($data["email"])) {
$this->email = $data["email"];
}
if (isset($data["password"])) {
$this->password = $data["password"];
}
if (isset($data["phone"])) {
$this->phone = $data["phone"];
}
if (isset($data["user_status"])) {
$this->user_status = $data["user_status"];
}
} }
} }
/**
* show all the invalid properties with reasons.
*
* @return array invalid properties with reasons
*/
public function list_invalid_properties()
{
$invalid_properties = array();
return $invalid_properties;
}
/**
* validate all the parameters in the model
* return true if all passed
*
* @return bool [description]
*/
public function valid()
{
return true;
}
/** /**
* Gets id * Gets id
* @return int * @return int
@@ -205,6 +279,7 @@ class User implements ArrayAccess
public function setId($id) public function setId($id)
{ {
$this->id = $id; $this->id = $id;
return $this; return $this;
} }
@@ -225,6 +300,7 @@ class User implements ArrayAccess
public function setUsername($username) public function setUsername($username)
{ {
$this->username = $username; $this->username = $username;
return $this; return $this;
} }
@@ -245,6 +321,7 @@ class User implements ArrayAccess
public function setFirstName($first_name) public function setFirstName($first_name)
{ {
$this->first_name = $first_name; $this->first_name = $first_name;
return $this; return $this;
} }
@@ -265,6 +342,7 @@ class User implements ArrayAccess
public function setLastName($last_name) public function setLastName($last_name)
{ {
$this->last_name = $last_name; $this->last_name = $last_name;
return $this; return $this;
} }
@@ -285,6 +363,7 @@ class User implements ArrayAccess
public function setEmail($email) public function setEmail($email)
{ {
$this->email = $email; $this->email = $email;
return $this; return $this;
} }
@@ -305,6 +384,7 @@ class User implements ArrayAccess
public function setPassword($password) public function setPassword($password)
{ {
$this->password = $password; $this->password = $password;
return $this; return $this;
} }
@@ -325,6 +405,7 @@ class User implements ArrayAccess
public function setPhone($phone) public function setPhone($phone)
{ {
$this->phone = $phone; $this->phone = $phone;
return $this; return $this;
} }
@@ -345,6 +426,7 @@ class User implements ArrayAccess
public function setUserStatus($user_status) public function setUserStatus($user_status)
{ {
$this->user_status = $user_status; $this->user_status = $user_status;
return $this; return $this;
} }