set allowablevalues of inner enum's allowablevalues

This commit is contained in:
wing328
2016-08-02 17:34:12 +08:00
parent bbe422947f
commit 0b8acb5b0c
14 changed files with 489 additions and 16 deletions

View File

@@ -0,0 +1,299 @@
<?php
/**
* EnumArrays
*
* PHP version 5
*
* @category Class
* @package Swagger\Client
* @author http://github.com/swagger-api/swagger-codegen
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
* @link https://github.com/swagger-api/swagger-codegen
*/
/**
* Swagger Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*
* 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.
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/
namespace Swagger\Client\Model;
use \ArrayAccess;
/**
* EnumArrays Class Doc Comment
*
* @category Class */
/**
* @package Swagger\Client
* @author http://github.com/swagger-api/swagger-codegen
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
* @link https://github.com/swagger-api/swagger-codegen
*/
class EnumArrays implements ArrayAccess
{
/**
* The original name of the model.
* @var string
*/
protected static $swaggerModelName = 'EnumArrays';
/**
* Array of property to type mappings. Used for (de)serialization
* @var string[]
*/
protected static $swaggerTypes = array(
'array_enum' => 'string[]',
'array_array_enum' => 'string[][]'
);
public static function swaggerTypes()
{
return self::$swaggerTypes;
}
/**
* Array of attributes where the key is the local name, and the value is the original name
* @var string[]
*/
protected static $attributeMap = array(
'array_enum' => 'array_enum',
'array_array_enum' => 'array_array_enum'
);
public static function attributeMap()
{
return self::$attributeMap;
}
/**
* Array of attributes to setter functions (for deserialization of responses)
* @var string[]
*/
protected static $setters = array(
'array_enum' => 'setArrayEnum',
'array_array_enum' => 'setArrayArrayEnum'
);
public static function setters()
{
return self::$setters;
}
/**
* Array of attributes to getter functions (for serialization of requests)
* @var string[]
*/
protected static $getters = array(
'array_enum' => 'getArrayEnum',
'array_array_enum' => 'getArrayArrayEnum'
);
public static function getters()
{
return self::$getters;
}
const ARRAY_ENUM[]_FISH = 'fish';
const ARRAY_ENUM[]_CRAB = 'crab';
const ARRAY_ARRAY_ENUM[][]_CAT = 'Cat';
const ARRAY_ARRAY_ENUM[][]_DOG = 'Dog';
/**
* Gets allowable values of the enum
* @return string[]
*/
public function getArrayEnumAllowableValues()
{
return [
self::ARRAY_ENUM[]_FISH,
self::ARRAY_ENUM[]_CRAB,
];
}
/**
* Gets allowable values of the enum
* @return string[]
*/
public function getArrayArrayEnumAllowableValues()
{
return [
self::ARRAY_ARRAY_ENUM[][]_CAT,
self::ARRAY_ARRAY_ENUM[][]_DOG,
];
}
/**
* Associative array for storing property values
* @var mixed[]
*/
protected $container = array();
/**
* Constructor
* @param mixed[] $data Associated array of property value initalizing the model
*/
public function __construct(array $data = null)
{
$this->container['array_enum'] = isset($data['array_enum']) ? $data['array_enum'] : null;
$this->container['array_array_enum'] = isset($data['array_array_enum']) ? $data['array_array_enum'] : null;
}
/**
* show all the invalid properties with reasons.
*
* @return array invalid properties with reasons
*/
public function listInvalidProperties()
{
$invalid_properties = array();
return $invalid_properties;
}
/**
* validate all the properties in the model
* return true if all passed
*
* @return bool True if all properteis are valid
*/
public function valid()
{
return true;
}
/**
* Gets array_enum
* @return string[]
*/
public function getArrayEnum()
{
return $this->container['array_enum'];
}
/**
* Sets array_enum
* @param string[] $array_enum
* @return $this
*/
public function setArrayEnum($array_enum)
{
$allowed_values = array('fish', 'crab');
if (!in_array($array_enum, $allowed_values)) {
throw new \InvalidArgumentException("Invalid value for 'array_enum', must be one of 'fish', 'crab'");
}
$this->container['array_enum'] = $array_enum;
return $this;
}
/**
* Gets array_array_enum
* @return string[][]
*/
public function getArrayArrayEnum()
{
return $this->container['array_array_enum'];
}
/**
* Sets array_array_enum
* @param string[][] $array_array_enum
* @return $this
*/
public function setArrayArrayEnum($array_array_enum)
{
$allowed_values = array('Cat', 'Dog');
if (!in_array($array_array_enum, $allowed_values)) {
throw new \InvalidArgumentException("Invalid value for 'array_array_enum', must be one of 'Cat', 'Dog'");
}
$this->container['array_array_enum'] = $array_array_enum;
return $this;
}
/**
* Returns true if offset exists. False otherwise.
* @param integer $offset Offset
* @return boolean
*/
public function offsetExists($offset)
{
return isset($this->container[$offset]);
}
/**
* Gets offset.
* @param integer $offset Offset
* @return mixed
*/
public function offsetGet($offset)
{
return isset($this->container[$offset]) ? $this->container[$offset] : null;
}
/**
* Sets value based on offset.
* @param integer $offset Offset
* @param mixed $value Value to be set
* @return void
*/
public function offsetSet($offset, $value)
{
if (is_null($offset)) {
$this->container[] = $value;
} else {
$this->container[$offset] = $value;
}
}
/**
* Unsets offset.
* @param integer $offset Offset
* @return void
*/
public function offsetUnset($offset)
{
unset($this->container[$offset]);
}
/**
* Gets the string presentation of the object
* @return string
*/
public function __toString()
{
if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT);
}
return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this));
}
}

View File

@@ -196,14 +196,17 @@ class EnumTest implements ArrayAccess
if (!in_array($this->container['enum_string'], $allowed_values)) {
$invalid_properties[] = "invalid value for 'enum_string', must be one of #{allowed_values}.";
}
$allowed_values = array("1", "-1");
if (!in_array($this->container['enum_integer'], $allowed_values)) {
$invalid_properties[] = "invalid value for 'enum_integer', must be one of #{allowed_values}.";
}
$allowed_values = array("1.1", "-1.2");
if (!in_array($this->container['enum_number'], $allowed_values)) {
$invalid_properties[] = "invalid value for 'enum_number', must be one of #{allowed_values}.";
}
return $invalid_properties;
}

View File

@@ -117,6 +117,8 @@ class MapTest implements ArrayAccess
return self::$getters;
}
const map[string,string]_UPPER = 'UPPER';
const map[string,string]_LOWER = 'lower';
@@ -127,7 +129,8 @@ class MapTest implements ArrayAccess
public function getMapOfEnumStringAllowableValues()
{
return [
self::map[string,string]_UPPER,
self::map[string,string]_LOWER,
];
}
@@ -156,10 +159,6 @@ class MapTest implements ArrayAccess
public function listInvalidProperties()
{
$invalid_properties = array();
$allowed_values = array();
if (!in_array($this->container['map_of_enum_string'], $allowed_values)) {
$invalid_properties[] = "invalid value for 'map_of_enum_string', must be one of #{allowed_values}.";
}
return $invalid_properties;
}
@@ -171,10 +170,6 @@ class MapTest implements ArrayAccess
*/
public function valid()
{
$allowed_values = array();
if (!in_array($this->container['map_of_enum_string'], $allowed_values)) {
return false;
}
return true;
}
@@ -216,9 +211,9 @@ class MapTest implements ArrayAccess
*/
public function setMapOfEnumString($map_of_enum_string)
{
$allowed_values = array();
$allowed_values = array('UPPER', 'lower');
if (!in_array($map_of_enum_string, $allowed_values)) {
throw new \InvalidArgumentException("Invalid value for 'map_of_enum_string', must be one of ");
throw new \InvalidArgumentException("Invalid value for 'map_of_enum_string', must be one of 'UPPER', 'lower'");
}
$this->container['map_of_enum_string'] = $map_of_enum_string;

View File

@@ -185,6 +185,7 @@ class Order implements ArrayAccess
if (!in_array($this->container['status'], $allowed_values)) {
$invalid_properties[] = "invalid value for 'status', must be one of #{allowed_values}.";
}
return $invalid_properties;
}

View File

@@ -191,6 +191,7 @@ class Pet implements ArrayAccess
if (!in_array($this->container['status'], $allowed_values)) {
$invalid_properties[] = "invalid value for 'status', must be one of #{allowed_values}.";
}
return $invalid_properties;
}