forked from loafle/openapi-generator-original
set allowablevalues of inner enum's allowablevalues
This commit is contained in:
parent
bbe422947f
commit
0b8acb5b0c
@ -1334,7 +1334,7 @@ public class DefaultCodegen {
|
|||||||
|
|
||||||
property.name = toVarName(name);
|
property.name = toVarName(name);
|
||||||
property.baseName = name;
|
property.baseName = name;
|
||||||
property.nameInCamelCase = camelize(name, false);
|
property.nameInCamelCase = camelize(property.name, false);
|
||||||
property.description = escapeText(p.getDescription());
|
property.description = escapeText(p.getDescription());
|
||||||
property.unescapedDescription = p.getDescription();
|
property.unescapedDescription = p.getDescription();
|
||||||
property.getter = "get" + getterAndSetterCapitalize(name);
|
property.getter = "get" + getterAndSetterCapitalize(name);
|
||||||
@ -1606,11 +1606,14 @@ public class DefaultCodegen {
|
|||||||
property.items = innerProperty;
|
property.items = innerProperty;
|
||||||
// inner item is Enum
|
// inner item is Enum
|
||||||
if (isPropertyInnerMostEnum(property)) {
|
if (isPropertyInnerMostEnum(property)) {
|
||||||
|
// isEnum is set to true when the type is an enum
|
||||||
|
// or the inner type of an array/map is an enum
|
||||||
property.isEnum = true;
|
property.isEnum = true;
|
||||||
// update datatypeWithEnum and default value for array
|
// update datatypeWithEnum and default value for array
|
||||||
// e.g. List<string> => List<StatusEnum>
|
// e.g. List<string> => List<StatusEnum>
|
||||||
updateDataTypeWithEnumForArray(property);
|
updateDataTypeWithEnumForArray(property);
|
||||||
|
// set allowable values to enum values (including array/map of enum)
|
||||||
|
property.allowableValues = getInnerEnumAllowableValues(property);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1633,10 +1636,14 @@ public class DefaultCodegen {
|
|||||||
property.items = innerProperty;
|
property.items = innerProperty;
|
||||||
// inner item is Enum
|
// inner item is Enum
|
||||||
if (isPropertyInnerMostEnum(property)) {
|
if (isPropertyInnerMostEnum(property)) {
|
||||||
|
// isEnum is set to true when the type is an enum
|
||||||
|
// or the inner type of an array/map is an enum
|
||||||
property.isEnum = true;
|
property.isEnum = true;
|
||||||
// update datatypeWithEnum and default value for map
|
// update datatypeWithEnum and default value for map
|
||||||
// e.g. Dictionary<string, string> => Dictionary<string, StatusEnum>
|
// e.g. Dictionary<string, string> => Dictionary<string, StatusEnum>
|
||||||
updateDataTypeWithEnumForMap(property);
|
updateDataTypeWithEnumForMap(property);
|
||||||
|
// set allowable values to enum values (including array/map of enum)
|
||||||
|
property.allowableValues = getInnerEnumAllowableValues(property);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1657,6 +1664,17 @@ public class DefaultCodegen {
|
|||||||
return currentProperty.isEnum;
|
return currentProperty.isEnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Map<String, Object> getInnerEnumAllowableValues(CodegenProperty property) {
|
||||||
|
CodegenProperty currentProperty = property;
|
||||||
|
while (currentProperty != null && (Boolean.TRUE.equals(currentProperty.isMapContainer)
|
||||||
|
|| Boolean.TRUE.equals(currentProperty.isListContainer))) {
|
||||||
|
currentProperty = currentProperty.items;
|
||||||
|
}
|
||||||
|
|
||||||
|
return currentProperty.allowableValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update datatypeWithEnum for array container
|
* Update datatypeWithEnum for array container
|
||||||
* @param property Codegen property
|
* @param property Codegen property
|
||||||
|
@ -121,36 +121,44 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple
|
|||||||
}
|
}
|
||||||
{{/required}}
|
{{/required}}
|
||||||
{{#isEnum}}
|
{{#isEnum}}
|
||||||
|
{{^isContainer}}
|
||||||
$allowed_values = array({{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}});
|
$allowed_values = array({{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}});
|
||||||
if (!in_array($this->container['{{name}}'], $allowed_values)) {
|
if (!in_array($this->container['{{name}}'], $allowed_values)) {
|
||||||
$invalid_properties[] = "invalid value for '{{name}}', must be one of #{allowed_values}.";
|
$invalid_properties[] = "invalid value for '{{name}}', must be one of #{allowed_values}.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{{/isContainer}}
|
||||||
{{/isEnum}}
|
{{/isEnum}}
|
||||||
{{#hasValidation}}
|
{{#hasValidation}}
|
||||||
{{#maxLength}}
|
{{#maxLength}}
|
||||||
if ({{^required}}!is_null($this->container['{{name}}']) && {{/required}}(strlen($this->container['{{name}}']) > {{maxLength}})) {
|
if ({{^required}}!is_null($this->container['{{name}}']) && {{/required}}(strlen($this->container['{{name}}']) > {{maxLength}})) {
|
||||||
$invalid_properties[] = "invalid value for '{{name}}', the character length must be smaller than or equal to {{{maxLength}}}.";
|
$invalid_properties[] = "invalid value for '{{name}}', the character length must be smaller than or equal to {{{maxLength}}}.";
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/maxLength}}
|
{{/maxLength}}
|
||||||
{{#minLength}}
|
{{#minLength}}
|
||||||
if ({{^required}}!is_null($this->container['{{name}}']) && {{/required}}(strlen($this->container['{{name}}']) < {{minLength}})) {
|
if ({{^required}}!is_null($this->container['{{name}}']) && {{/required}}(strlen($this->container['{{name}}']) < {{minLength}})) {
|
||||||
$invalid_properties[] = "invalid value for '{{name}}', the character length must be bigger than or equal to {{{minLength}}}.";
|
$invalid_properties[] = "invalid value for '{{name}}', the character length must be bigger than or equal to {{{minLength}}}.";
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/minLength}}
|
{{/minLength}}
|
||||||
{{#maximum}}
|
{{#maximum}}
|
||||||
if ({{^required}}!is_null($this->container['{{name}}']) && {{/required}}($this->container['{{name}}'] > {{maximum}})) {
|
if ({{^required}}!is_null($this->container['{{name}}']) && {{/required}}($this->container['{{name}}'] > {{maximum}})) {
|
||||||
$invalid_properties[] = "invalid value for '{{name}}', must be smaller than or equal to {{maximum}}.";
|
$invalid_properties[] = "invalid value for '{{name}}', must be smaller than or equal to {{maximum}}.";
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/maximum}}
|
{{/maximum}}
|
||||||
{{#minimum}}
|
{{#minimum}}
|
||||||
if ({{^required}}!is_null($this->container['{{name}}']) && {{/required}}($this->container['{{name}}'] < {{minimum}})) {
|
if ({{^required}}!is_null($this->container['{{name}}']) && {{/required}}($this->container['{{name}}'] < {{minimum}})) {
|
||||||
$invalid_properties[] = "invalid value for '{{name}}', must be bigger than or equal to {{minimum}}.";
|
$invalid_properties[] = "invalid value for '{{name}}', must be bigger than or equal to {{minimum}}.";
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/minimum}}
|
{{/minimum}}
|
||||||
{{#pattern}}
|
{{#pattern}}
|
||||||
if ({{^required}}!is_null($this->container['{{name}}']) && {{/required}}!preg_match("{{pattern}}", $this->container['{{name}}'])) {
|
if ({{^required}}!is_null($this->container['{{name}}']) && {{/required}}!preg_match("{{pattern}}", $this->container['{{name}}'])) {
|
||||||
$invalid_properties[] = "invalid value for '{{name}}', must be conform to the pattern {{pattern}}.";
|
$invalid_properties[] = "invalid value for '{{name}}', must be conform to the pattern {{pattern}}.";
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/pattern}}
|
{{/pattern}}
|
||||||
{{/hasValidation}}
|
{{/hasValidation}}
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
@ -172,10 +180,12 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple
|
|||||||
}
|
}
|
||||||
{{/required}}
|
{{/required}}
|
||||||
{{#isEnum}}
|
{{#isEnum}}
|
||||||
|
{{^isContainer}}
|
||||||
$allowed_values = array({{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}});
|
$allowed_values = array({{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}});
|
||||||
if (!in_array($this->container['{{name}}'], $allowed_values)) {
|
if (!in_array($this->container['{{name}}'], $allowed_values)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
{{/isContainer}}
|
||||||
{{/isEnum}}
|
{{/isEnum}}
|
||||||
{{#hasValidation}}
|
{{#hasValidation}}
|
||||||
{{#maxLength}}
|
{{#maxLength}}
|
||||||
|
@ -1143,6 +1143,25 @@ definitions:
|
|||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
type: number
|
type: number
|
||||||
|
EnumArrays:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
array_enum:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- fish
|
||||||
|
- crab
|
||||||
|
array_array_enum:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- Cat
|
||||||
|
- Dog
|
||||||
externalDocs:
|
externalDocs:
|
||||||
description: Find out more about Swagger
|
description: Find out more about Swagger
|
||||||
url: 'http://swagger.io'
|
url: 'http://swagger.io'
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
# EnumArrays
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**array_enum** | **string[]** | | [optional]
|
||||||
|
**array_array_enum** | [**string[][]**](array.md) | | [optional]
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -196,14 +196,17 @@ class EnumTest implements ArrayAccess
|
|||||||
if (!in_array($this->container['enum_string'], $allowed_values)) {
|
if (!in_array($this->container['enum_string'], $allowed_values)) {
|
||||||
$invalid_properties[] = "invalid value for 'enum_string', must be one of #{allowed_values}.";
|
$invalid_properties[] = "invalid value for 'enum_string', must be one of #{allowed_values}.";
|
||||||
}
|
}
|
||||||
|
|
||||||
$allowed_values = array("1", "-1");
|
$allowed_values = array("1", "-1");
|
||||||
if (!in_array($this->container['enum_integer'], $allowed_values)) {
|
if (!in_array($this->container['enum_integer'], $allowed_values)) {
|
||||||
$invalid_properties[] = "invalid value for 'enum_integer', must be one of #{allowed_values}.";
|
$invalid_properties[] = "invalid value for 'enum_integer', must be one of #{allowed_values}.";
|
||||||
}
|
}
|
||||||
|
|
||||||
$allowed_values = array("1.1", "-1.2");
|
$allowed_values = array("1.1", "-1.2");
|
||||||
if (!in_array($this->container['enum_number'], $allowed_values)) {
|
if (!in_array($this->container['enum_number'], $allowed_values)) {
|
||||||
$invalid_properties[] = "invalid value for 'enum_number', must be one of #{allowed_values}.";
|
$invalid_properties[] = "invalid value for 'enum_number', must be one of #{allowed_values}.";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $invalid_properties;
|
return $invalid_properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,6 +117,8 @@ class MapTest implements ArrayAccess
|
|||||||
return self::$getters;
|
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()
|
public function getMapOfEnumStringAllowableValues()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
self::map[string,string]_UPPER,
|
||||||
|
self::map[string,string]_LOWER,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,10 +159,6 @@ class MapTest implements ArrayAccess
|
|||||||
public function listInvalidProperties()
|
public function listInvalidProperties()
|
||||||
{
|
{
|
||||||
$invalid_properties = array();
|
$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;
|
return $invalid_properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,10 +170,6 @@ class MapTest implements ArrayAccess
|
|||||||
*/
|
*/
|
||||||
public function valid()
|
public function valid()
|
||||||
{
|
{
|
||||||
$allowed_values = array();
|
|
||||||
if (!in_array($this->container['map_of_enum_string'], $allowed_values)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,9 +211,9 @@ class MapTest implements ArrayAccess
|
|||||||
*/
|
*/
|
||||||
public function setMapOfEnumString($map_of_enum_string)
|
public function setMapOfEnumString($map_of_enum_string)
|
||||||
{
|
{
|
||||||
$allowed_values = array();
|
$allowed_values = array('UPPER', 'lower');
|
||||||
if (!in_array($map_of_enum_string, $allowed_values)) {
|
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;
|
$this->container['map_of_enum_string'] = $map_of_enum_string;
|
||||||
|
|
||||||
|
@ -185,6 +185,7 @@ class Order implements ArrayAccess
|
|||||||
if (!in_array($this->container['status'], $allowed_values)) {
|
if (!in_array($this->container['status'], $allowed_values)) {
|
||||||
$invalid_properties[] = "invalid value for 'status', must be one of #{allowed_values}.";
|
$invalid_properties[] = "invalid value for 'status', must be one of #{allowed_values}.";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $invalid_properties;
|
return $invalid_properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,6 +191,7 @@ class Pet implements ArrayAccess
|
|||||||
if (!in_array($this->container['status'], $allowed_values)) {
|
if (!in_array($this->container['status'], $allowed_values)) {
|
||||||
$invalid_properties[] = "invalid value for 'status', must be one of #{allowed_values}.";
|
$invalid_properties[] = "invalid value for 'status', must be one of #{allowed_values}.";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $invalid_properties;
|
return $invalid_properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ class ObjectSerializer
|
|||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} elseif (in_array($class, array('void', 'bool', 'string', 'double', 'byte', 'mixed', 'integer', 'float', 'int', 'DateTime', 'number', 'boolean', 'object'))) {
|
} elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) {
|
||||||
settype($data, $class);
|
settype($data, $class);
|
||||||
return $data;
|
return $data;
|
||||||
} elseif ($class === '\SplFileObject') {
|
} elseif ($class === '\SplFileObject') {
|
||||||
|
@ -0,0 +1,114 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* EnumArraysTest
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* Please update the test case below to test the model.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Swagger\Client;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EnumArraysTest Class Doc Comment
|
||||||
|
*
|
||||||
|
* @category Class */
|
||||||
|
// * @description EnumArrays
|
||||||
|
/**
|
||||||
|
* @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 EnumArraysTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup before running any test case
|
||||||
|
*/
|
||||||
|
public static function setUpBeforeClass()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup before running each test case
|
||||||
|
*/
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clean up after running each test case
|
||||||
|
*/
|
||||||
|
public function tearDown()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clean up after running all test cases
|
||||||
|
*/
|
||||||
|
public static function tearDownAfterClass()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test "EnumArrays"
|
||||||
|
*/
|
||||||
|
public function testEnumArrays()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test attribute "array_enum"
|
||||||
|
*/
|
||||||
|
public function testPropertyArrayEnum()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test attribute "array_array_enum"
|
||||||
|
*/
|
||||||
|
public function testPropertyArrayArrayEnum()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -98,7 +98,7 @@ class ModelListTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* Test attribute "_123_list"
|
* Test attribute "_123_list"
|
||||||
*/
|
*/
|
||||||
public function testProperty123-list()
|
public function testProperty123List()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/
|
|||||||
|
|
||||||
- API version: 1.0.0
|
- API version: 1.0.0
|
||||||
- Package version: 1.0.0
|
- Package version: 1.0.0
|
||||||
- Build date: 2016-08-01T16:37:23.828+08:00
|
- Build date: 2016-08-01T21:53:35.575+08:00
|
||||||
- Build package: class io.swagger.codegen.languages.RubyClientCodegen
|
- Build package: class io.swagger.codegen.languages.RubyClientCodegen
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
@ -114,6 +114,7 @@ Class | Method | HTTP request | Description
|
|||||||
- [Petstore::Category](docs/Category.md)
|
- [Petstore::Category](docs/Category.md)
|
||||||
- [Petstore::Client](docs/Client.md)
|
- [Petstore::Client](docs/Client.md)
|
||||||
- [Petstore::Dog](docs/Dog.md)
|
- [Petstore::Dog](docs/Dog.md)
|
||||||
|
- [Petstore::EnumArrays](docs/EnumArrays.md)
|
||||||
- [Petstore::EnumClass](docs/EnumClass.md)
|
- [Petstore::EnumClass](docs/EnumClass.md)
|
||||||
- [Petstore::EnumTest](docs/EnumTest.md)
|
- [Petstore::EnumTest](docs/EnumTest.md)
|
||||||
- [Petstore::FormatTest](docs/FormatTest.md)
|
- [Petstore::FormatTest](docs/FormatTest.md)
|
||||||
|
@ -39,6 +39,7 @@ require 'petstore/models/cat'
|
|||||||
require 'petstore/models/category'
|
require 'petstore/models/category'
|
||||||
require 'petstore/models/client'
|
require 'petstore/models/client'
|
||||||
require 'petstore/models/dog'
|
require 'petstore/models/dog'
|
||||||
|
require 'petstore/models/enum_arrays'
|
||||||
require 'petstore/models/enum_class'
|
require 'petstore/models/enum_class'
|
||||||
require 'petstore/models/enum_test'
|
require 'petstore/models/enum_test'
|
||||||
require 'petstore/models/format_test'
|
require 'petstore/models/format_test'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user