php-laravel, enum models, nullable and default values (#12480)

* + support for enum models & separating mustache templates for enums and generics
+ extract property 'type' and 'default value' from a #ref to an enum model
+ support for `PascalCase` naming convention for PHP generators
+ use a default value for known basic types when they are not nullable
+ use 'null' as default value for nullable types when they do not specify the default value
+ use defined constant path as enum default value when found

* + sample output update

* + change model fields to be public and acessible from outside

* + sample output update

Co-authored-by: Mostafa Aghajani <mostafa.aghajani@virta.global>
This commit is contained in:
William Cheng 2022-05-27 11:16:26 +08:00 committed by GitHub
parent 5307a8dafd
commit 76eddeb713
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
54 changed files with 427 additions and 165 deletions

View File

@ -408,6 +408,8 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
// return the name in camelCase style // return the name in camelCase style
// phone_number => phoneNumber // phone_number => phoneNumber
name = camelize(name, true); name = camelize(name, true);
} else if ("PascalCase".equals(variableNamingConvention)) {
name = camelize(name, false);
} else { // default to snake case } else { // default to snake case
// return the name in underscore style // return the name in underscore style
// PhoneNumber => phone_number // PhoneNumber => phone_number

View File

@ -18,12 +18,16 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.openapitools.codegen.CodegenOperation; import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType; import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile; import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.meta.features.*; import org.openapitools.codegen.meta.features.*;
import org.openapitools.codegen.model.ModelMap; import org.openapitools.codegen.model.ModelMap;
import org.openapitools.codegen.model.OperationMap; import org.openapitools.codegen.model.OperationMap;
import org.openapitools.codegen.model.OperationsMap; import org.openapitools.codegen.model.OperationsMap;
import org.openapitools.codegen.utils.ModelUtils;
import io.swagger.v3.oas.models.media.Schema;
import java.io.File; import java.io.File;
import java.util.*; import java.util.*;
@ -296,4 +300,96 @@ public class PhpLaravelServerCodegen extends AbstractPhpCodegen {
return camelize(name, false) + "Controller"; return camelize(name, false) + "Controller";
} }
@Override
protected String getEnumDefaultValue(String defaultValue, String dataType) {
return defaultValue;
}
@Override
public CodegenProperty fromProperty(String name, Schema p) {
CodegenProperty property = super.fromProperty(name, p);
Schema referencedSchema = ModelUtils.getReferencedSchema(this.openAPI, p);
//Referenced enum case:
if (!property.isEnum && referencedSchema.getEnum() != null && !referencedSchema.getEnum().isEmpty()) {
property.dataType = this.getSchemaType(referencedSchema);
property.defaultValue = this.toDefaultValue(referencedSchema);
List<Object> _enum = referencedSchema.getEnum();
Map<String, Object> allowableValues = new HashMap<>();
allowableValues.put("values", _enum);
if (allowableValues.size() > 0) {
property.allowableValues = allowableValues;
}
}
return property;
}
@Override
public String toDefaultValue(Schema p) {
if (ModelUtils.isBooleanSchema(p)) {
if (p.getDefault() != null) {
return p.getDefault().toString();
} else if (!Boolean.TRUE.equals(p.getNullable())) {
return "false";
}
} else if (ModelUtils.isDateSchema(p)) {
// TODO
} else if (ModelUtils.isDateTimeSchema(p)) {
// TODO
} else if (ModelUtils.isFileSchema(p)) {
// TODO
} else if (ModelUtils.isNumberSchema(p)) {
if (p.getDefault() != null) {
return p.getDefault().toString();
} else if (!Boolean.TRUE.equals(p.getNullable())) {
return "0";
}
} else if (ModelUtils.isIntegerSchema(p)) {
if (p.getDefault() != null) {
return p.getDefault().toString();
} else if (!Boolean.TRUE.equals(p.getNullable())) {
return "0";
}
} else if (ModelUtils.isStringSchema(p)) {
if (p.getDefault() != null) {
return "'" + p.getDefault() + "'";
} else if (!Boolean.TRUE.equals(p.getNullable())) {
return "\"\"";
}
} else if (ModelUtils.isArraySchema(p)) {
if (p.getDefault() != null) {
return p.getDefault().toString();
} else if (!Boolean.TRUE.equals(p.getNullable())) {
return "[]";
}
}
return null;
}
@Override
public String toEnumDefaultValue(String value, String datatype) {
return datatype + "::" + value;
}
@Override
public String toEnumVarName(String value, String datatype) {
if (value.length() == 0) {
return super.toEnumVarName(value, datatype);
}
// number
if ("int".equals(datatype) || "double".equals(datatype) || "float".equals(datatype)) {
String varName = "NUMBER_" + value;
varName = varName.replaceAll("-", "MINUS_");
varName = varName.replaceAll("\\+", "PLUS_");
varName = varName.replaceAll("\\.", "_DOT_");
return varName;
}
return super.toEnumVarName(value, datatype);
}
} }

View File

@ -1,21 +1,17 @@
<?php <?php
{{#models}}{{#model}}/** {{#models}}
{{#model}}
/**
* {{classname}} * {{classname}}
*/ */
namespace {{modelPackage}}; namespace {{modelPackage}};
/** /**
* {{classname}} * {{classname}}
{{#description}}
* @description {{{.}}}
{{/description}}
*/ */
class {{classname}} { {{#isEnum}}{{>model_enum}}{{/isEnum}}{{^isEnum}}{{>model_generic}}{{/isEnum}}
{{/model}}
{{#vars}} {{/models}}
/** @var {{{dataType}}} ${{name}} {{description}}*/
{{#deprecated}}
/** @deprecated */
{{/deprecated}}
private ${{name}};
{{/vars}}
}
{{/model}}{{/models}}

View File

@ -0,0 +1,28 @@
class {{classname}}
{
/**
* Possible values of this enum
*/
{{#allowableValues}}
{{#enumVars}}
const {{{name}}} = {{{value}}};
{{/enumVars}}
{{/allowableValues}}
/**
* Gets allowable values of the enum
* @return string[]
*/
public static function getAllowableEnumValues()
{
return [
{{#allowableValues}}
{{#enumVars}}
self::{{{name}}}{{^-last}},
{{/-last}}
{{/enumVars}}
{{/allowableValues}}
];
}
}

View File

@ -0,0 +1,11 @@
class {{classname}} {
{{#vars}}
/** @var {{{dataType}}}{{#isNullable}}|null{{/isNullable}} ${{name}} {{description}}*/
{{#deprecated}}
/** @deprecated */
{{/deprecated}}
public ${{name}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}{{#isNullable}} = null{{/isNullable}}{{/defaultValue}};
{{/vars}}
}

View File

@ -10,9 +10,9 @@ namespace app\Models;
class AdditionalPropertiesClass { class AdditionalPropertiesClass {
/** @var array<string,string> $mapProperty */ /** @var array<string,string> $mapProperty */
private $mapProperty; public $mapProperty;
/** @var array<string,array<string,string>> $mapOfMapProperty */ /** @var array<string,array<string,string>> $mapOfMapProperty */
private $mapOfMapProperty; public $mapOfMapProperty;
} }

View File

@ -10,9 +10,9 @@ namespace app\Models;
class AllOfWithSingleRef { class AllOfWithSingleRef {
/** @var string $username */ /** @var string $username */
private $username; public $username = "";
/** @var SingleRefType $singleRefType */ /** @var SingleRefType|null $singleRefType */
private $singleRefType; public $singleRefType = null;
} }

View File

@ -10,9 +10,9 @@ namespace app\Models;
class Animal { class Animal {
/** @var string $className */ /** @var string $className */
private $className; public $className = "";
/** @var string $color */ /** @var string $color */
private $color; public $color = 'red';
} }

View File

@ -10,12 +10,12 @@ namespace app\Models;
class ApiResponse { class ApiResponse {
/** @var int $code */ /** @var int $code */
private $code; public $code = 0;
/** @var string $type */ /** @var string $type */
private $type; public $type = "";
/** @var string $message */ /** @var string $message */
private $message; public $message = "";
} }

View File

@ -10,6 +10,6 @@ namespace app\Models;
class ArrayOfArrayOfNumberOnly { class ArrayOfArrayOfNumberOnly {
/** @var float[][] $arrayArrayNumber */ /** @var float[][] $arrayArrayNumber */
private $arrayArrayNumber; public $arrayArrayNumber = [];
} }

View File

@ -10,6 +10,6 @@ namespace app\Models;
class ArrayOfNumberOnly { class ArrayOfNumberOnly {
/** @var float[] $arrayNumber */ /** @var float[] $arrayNumber */
private $arrayNumber; public $arrayNumber = [];
} }

View File

@ -10,12 +10,12 @@ namespace app\Models;
class ArrayTest { class ArrayTest {
/** @var string[] $arrayOfString */ /** @var string[] $arrayOfString */
private $arrayOfString; public $arrayOfString = [];
/** @var int[][] $arrayArrayOfInteger */ /** @var int[][] $arrayArrayOfInteger */
private $arrayArrayOfInteger; public $arrayArrayOfInteger = [];
/** @var \app\Models\ReadOnlyFirst[][] $arrayArrayOfModel */ /** @var \app\Models\ReadOnlyFirst[][] $arrayArrayOfModel */
private $arrayArrayOfModel; public $arrayArrayOfModel = [];
} }

View File

@ -10,21 +10,21 @@ namespace app\Models;
class Capitalization { class Capitalization {
/** @var string $smallCamel */ /** @var string $smallCamel */
private $smallCamel; public $smallCamel = "";
/** @var string $capitalCamel */ /** @var string $capitalCamel */
private $capitalCamel; public $capitalCamel = "";
/** @var string $smallSnake */ /** @var string $smallSnake */
private $smallSnake; public $smallSnake = "";
/** @var string $capitalSnake */ /** @var string $capitalSnake */
private $capitalSnake; public $capitalSnake = "";
/** @var string $sCAETHFlowPoints */ /** @var string $sCAETHFlowPoints */
private $sCAETHFlowPoints; public $sCAETHFlowPoints = "";
/** @var string $aTTNAME Name of the pet*/ /** @var string $aTTNAME Name of the pet*/
private $aTTNAME; public $aTTNAME = "";
} }

View File

@ -10,12 +10,12 @@ namespace app\Models;
class Cat { class Cat {
/** @var string $className */ /** @var string $className */
private $className; public $className = "";
/** @var string $color */ /** @var string $color */
private $color; public $color = 'red';
/** @var bool $declawed */ /** @var bool $declawed */
private $declawed; public $declawed = false;
} }

View File

@ -10,6 +10,6 @@ namespace app\Models;
class CatAllOf { class CatAllOf {
/** @var bool $declawed */ /** @var bool $declawed */
private $declawed; public $declawed = false;
} }

View File

@ -10,9 +10,9 @@ namespace app\Models;
class Category { class Category {
/** @var int $id */ /** @var int $id */
private $id; public $id = 0;
/** @var string $name */ /** @var string $name */
private $name; public $name = 'default-name';
} }

View File

@ -6,10 +6,11 @@ namespace app\Models;
/** /**
* ClassModel * ClassModel
* @description Model for testing model with \"_class\" property
*/ */
class ClassModel { class ClassModel {
/** @var string $class */ /** @var string $class */
private $class; public $class = "";
} }

View File

@ -10,6 +10,6 @@ namespace app\Models;
class Client { class Client {
/** @var string $client */ /** @var string $client */
private $client; public $client = "";
} }

View File

@ -10,6 +10,6 @@ namespace app\Models;
class DeprecatedObject { class DeprecatedObject {
/** @var string $name */ /** @var string $name */
private $name; public $name = "";
} }

View File

@ -10,12 +10,12 @@ namespace app\Models;
class Dog { class Dog {
/** @var string $className */ /** @var string $className */
private $className; public $className = "";
/** @var string $color */ /** @var string $color */
private $color; public $color = 'red';
/** @var string $breed */ /** @var string $breed */
private $breed; public $breed = "";
} }

View File

@ -10,6 +10,6 @@ namespace app\Models;
class DogAllOf { class DogAllOf {
/** @var string $breed */ /** @var string $breed */
private $breed; public $breed = "";
} }

View File

@ -10,9 +10,9 @@ namespace app\Models;
class EnumArrays { class EnumArrays {
/** @var string $justSymbol */ /** @var string $justSymbol */
private $justSymbol; public $justSymbol = "";
/** @var string[] $arrayEnum */ /** @var string[] $arrayEnum */
private $arrayEnum; public $arrayEnum = [];
} }

View File

@ -7,6 +7,27 @@ namespace app\Models;
/** /**
* EnumClass * EnumClass
*/ */
class EnumClass { class EnumClass
{
/**
* Possible values of this enum
*/
const ABC = '_abc';
const EFG = '-efg';
const XYZ = '(xyz)';
/**
* Gets allowable values of the enum
* @return string[]
*/
public static function getAllowableEnumValues()
{
return [
self::ABC,
self::EFG,
self::XYZ
];
}
} }

View File

@ -10,27 +10,27 @@ namespace app\Models;
class EnumTest { class EnumTest {
/** @var string $enumString */ /** @var string $enumString */
private $enumString; public $enumString = "";
/** @var string $enumStringRequired */ /** @var string $enumStringRequired */
private $enumStringRequired; public $enumStringRequired = "";
/** @var int $enumInteger */ /** @var int $enumInteger */
private $enumInteger; public $enumInteger = 0;
/** @var double $enumNumber */ /** @var double $enumNumber */
private $enumNumber; public $enumNumber = 0;
/** @var \app\Models\OuterEnum $outerEnum */ /** @var string|null $outerEnum */
private $outerEnum; public $outerEnum = null;
/** @var \app\Models\OuterEnumInteger $outerEnumInteger */ /** @var int $outerEnumInteger */
private $outerEnumInteger; public $outerEnumInteger = \app\Models\OuterEnumInteger::NUMBER_0;
/** @var \app\Models\OuterEnumDefaultValue $outerEnumDefaultValue */ /** @var string $outerEnumDefaultValue */
private $outerEnumDefaultValue; public $outerEnumDefaultValue = \app\Models\OuterEnumDefaultValue::PLACED;
/** @var \app\Models\OuterEnumIntegerDefaultValue $outerEnumIntegerDefaultValue */ /** @var int $outerEnumIntegerDefaultValue */
private $outerEnumIntegerDefaultValue; public $outerEnumIntegerDefaultValue = \app\Models\OuterEnumIntegerDefaultValue::NUMBER_0;
} }

View File

@ -6,10 +6,11 @@ namespace app\Models;
/** /**
* File * File
* @description Must be named `File` for test.
*/ */
class File { class File {
/** @var string $sourceURI Test capitalization*/ /** @var string $sourceURI Test capitalization*/
private $sourceURI; public $sourceURI = "";
} }

View File

@ -10,9 +10,9 @@ namespace app\Models;
class FileSchemaTestClass { class FileSchemaTestClass {
/** @var \app\Models\File $file */ /** @var \app\Models\File $file */
private $file; public $file;
/** @var \app\Models\File[] $files */ /** @var \app\Models\File[] $files */
private $files; public $files = [];
} }

View File

@ -10,6 +10,6 @@ namespace app\Models;
class Foo { class Foo {
/** @var string $bar */ /** @var string $bar */
private $bar; public $bar = 'bar';
} }

View File

@ -10,6 +10,6 @@ namespace app\Models;
class FooGetDefaultResponse { class FooGetDefaultResponse {
/** @var \app\Models\Foo $string */ /** @var \app\Models\Foo $string */
private $string; public $string;
} }

View File

@ -10,51 +10,51 @@ namespace app\Models;
class FormatTest { class FormatTest {
/** @var int $integer */ /** @var int $integer */
private $integer; public $integer = 0;
/** @var int $int32 */ /** @var int $int32 */
private $int32; public $int32 = 0;
/** @var int $int64 */ /** @var int $int64 */
private $int64; public $int64 = 0;
/** @var float $number */ /** @var float $number */
private $number; public $number = 0;
/** @var float $float */ /** @var float $float */
private $float; public $float = 0;
/** @var double $double */ /** @var double $double */
private $double; public $double = 0;
/** @var float $decimal */ /** @var float $decimal */
private $decimal; public $decimal = "";
/** @var string $string */ /** @var string $string */
private $string; public $string = "";
/** @var string $byte */ /** @var string $byte */
private $byte; public $byte = "";
/** @var \SplFileObject $binary */ /** @var \SplFileObject $binary */
private $binary; public $binary;
/** @var \DateTime $date */ /** @var \DateTime $date */
private $date; public $date;
/** @var \DateTime $dateTime */ /** @var \DateTime $dateTime */
private $dateTime; public $dateTime;
/** @var string $uuid */ /** @var string $uuid */
private $uuid; public $uuid = "";
/** @var string $password */ /** @var string $password */
private $password; public $password = "";
/** @var string $patternWithDigits A string that is a 10 digit number. Can have leading zeros.*/ /** @var string $patternWithDigits A string that is a 10 digit number. Can have leading zeros.*/
private $patternWithDigits; public $patternWithDigits = "";
/** @var string $patternWithDigitsAndDelimiter A string starting with &#39;image_&#39; (case insensitive) and one to three digits following i.e. Image_01.*/ /** @var string $patternWithDigitsAndDelimiter A string starting with &#39;image_&#39; (case insensitive) and one to three digits following i.e. Image_01.*/
private $patternWithDigitsAndDelimiter; public $patternWithDigitsAndDelimiter = "";
} }

View File

@ -10,9 +10,9 @@ namespace app\Models;
class HasOnlyReadOnly { class HasOnlyReadOnly {
/** @var string $bar */ /** @var string $bar */
private $bar; public $bar = "";
/** @var string $foo */ /** @var string $foo */
private $foo; public $foo = "";
} }

View File

@ -6,10 +6,11 @@ namespace app\Models;
/** /**
* HealthCheckResult * HealthCheckResult
* @description Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model.
*/ */
class HealthCheckResult { class HealthCheckResult {
/** @var string $nullableMessage */ /** @var string|null $nullableMessage */
private $nullableMessage; public $nullableMessage = null;
} }

View File

@ -10,6 +10,6 @@ namespace app\Models;
class InlineResponseDefault { class InlineResponseDefault {
/** @var \app\Models\Foo $string */ /** @var \app\Models\Foo $string */
private $string; public $string;
} }

View File

@ -10,15 +10,15 @@ namespace app\Models;
class MapTest { class MapTest {
/** @var array<string,array<string,string>> $mapMapOfString */ /** @var array<string,array<string,string>> $mapMapOfString */
private $mapMapOfString; public $mapMapOfString;
/** @var array<string,string> $mapOfEnumString */ /** @var array<string,string> $mapOfEnumString */
private $mapOfEnumString; public $mapOfEnumString;
/** @var array<string,bool> $directMap */ /** @var array<string,bool> $directMap */
private $directMap; public $directMap;
/** @var array<string,bool> $indirectMap */ /** @var array<string,bool> $indirectMap */
private $indirectMap; public $indirectMap;
} }

View File

@ -10,12 +10,12 @@ namespace app\Models;
class MixedPropertiesAndAdditionalPropertiesClass { class MixedPropertiesAndAdditionalPropertiesClass {
/** @var string $uuid */ /** @var string $uuid */
private $uuid; public $uuid = "";
/** @var \DateTime $dateTime */ /** @var \DateTime $dateTime */
private $dateTime; public $dateTime;
/** @var array<string,\app\Models\Animal> $map */ /** @var array<string,\app\Models\Animal> $map */
private $map; public $map;
} }

View File

@ -6,13 +6,14 @@ namespace app\Models;
/** /**
* Model200Response * Model200Response
* @description Model for testing model name starting with number
*/ */
class Model200Response { class Model200Response {
/** @var int $name */ /** @var int $name */
private $name; public $name = 0;
/** @var string $class */ /** @var string $class */
private $class; public $class = "";
} }

View File

@ -10,6 +10,6 @@ namespace app\Models;
class ModelList { class ModelList {
/** @var string $_123list */ /** @var string $_123list */
private $_123list; public $_123list = "";
} }

View File

@ -6,10 +6,11 @@ namespace app\Models;
/** /**
* ModelReturn * ModelReturn
* @description Model for testing reserved words
*/ */
class ModelReturn { class ModelReturn {
/** @var int $return */ /** @var int $return */
private $return; public $return = 0;
} }

View File

@ -6,19 +6,20 @@ namespace app\Models;
/** /**
* Name * Name
* @description Model for testing model name same as property name
*/ */
class Name { class Name {
/** @var int $name */ /** @var int $name */
private $name; public $name = 0;
/** @var int $snakeCase */ /** @var int $snakeCase */
private $snakeCase; public $snakeCase = 0;
/** @var string $property */ /** @var string $property */
private $property; public $property = "";
/** @var int $_123number */ /** @var int $_123number */
private $_123number; public $_123number = 0;
} }

View File

@ -9,40 +9,40 @@ namespace app\Models;
*/ */
class NullableClass { class NullableClass {
/** @var int $integerProp */ /** @var int|null $integerProp */
private $integerProp; public $integerProp = null;
/** @var float $numberProp */ /** @var float|null $numberProp */
private $numberProp; public $numberProp = null;
/** @var bool $booleanProp */ /** @var bool|null $booleanProp */
private $booleanProp; public $booleanProp = null;
/** @var string $stringProp */ /** @var string|null $stringProp */
private $stringProp; public $stringProp = null;
/** @var \DateTime $dateProp */ /** @var \DateTime|null $dateProp */
private $dateProp; public $dateProp = null;
/** @var \DateTime $datetimeProp */ /** @var \DateTime|null $datetimeProp */
private $datetimeProp; public $datetimeProp = null;
/** @var object[] $arrayNullableProp */ /** @var object[]|null $arrayNullableProp */
private $arrayNullableProp; public $arrayNullableProp = null;
/** @var object[] $arrayAndItemsNullableProp */ /** @var object[]|null $arrayAndItemsNullableProp */
private $arrayAndItemsNullableProp; public $arrayAndItemsNullableProp = null;
/** @var object[] $arrayItemsNullable */ /** @var object[] $arrayItemsNullable */
private $arrayItemsNullable; public $arrayItemsNullable = [];
/** @var array<string,object> $objectNullableProp */ /** @var array<string,object>|null $objectNullableProp */
private $objectNullableProp; public $objectNullableProp = null;
/** @var array<string,object> $objectAndItemsNullableProp */ /** @var array<string,object>|null $objectAndItemsNullableProp */
private $objectAndItemsNullableProp; public $objectAndItemsNullableProp = null;
/** @var array<string,object> $objectItemsNullable */ /** @var array<string,object> $objectItemsNullable */
private $objectItemsNullable; public $objectItemsNullable;
} }

View File

@ -10,6 +10,6 @@ namespace app\Models;
class NumberOnly { class NumberOnly {
/** @var float $justNumber */ /** @var float $justNumber */
private $justNumber; public $justNumber = 0;
} }

View File

@ -10,18 +10,18 @@ namespace app\Models;
class ObjectWithDeprecatedFields { class ObjectWithDeprecatedFields {
/** @var string $uuid */ /** @var string $uuid */
private $uuid; public $uuid = "";
/** @var float $id */ /** @var float $id */
/** @deprecated */ /** @deprecated */
private $id; public $id = 0;
/** @var \app\Models\DeprecatedObject $deprecatedRef */ /** @var \app\Models\DeprecatedObject $deprecatedRef */
/** @deprecated */ /** @deprecated */
private $deprecatedRef; public $deprecatedRef;
/** @var string[] $bars */ /** @var string[] $bars */
/** @deprecated */ /** @deprecated */
private $bars; public $bars = [];
} }

View File

@ -10,21 +10,21 @@ namespace app\Models;
class Order { class Order {
/** @var int $id */ /** @var int $id */
private $id; public $id = 0;
/** @var int $petId */ /** @var int $petId */
private $petId; public $petId = 0;
/** @var int $quantity */ /** @var int $quantity */
private $quantity; public $quantity = 0;
/** @var \DateTime $shipDate */ /** @var \DateTime $shipDate */
private $shipDate; public $shipDate;
/** @var string $status Order Status*/ /** @var string $status Order Status*/
private $status; public $status = "";
/** @var bool $complete */ /** @var bool $complete */
private $complete; public $complete = false;
} }

View File

@ -10,12 +10,12 @@ namespace app\Models;
class OuterComposite { class OuterComposite {
/** @var float $myNumber */ /** @var float $myNumber */
private $myNumber; public $myNumber = 0;
/** @var string $myString */ /** @var string $myString */
private $myString; public $myString = "";
/** @var bool $myBoolean */ /** @var bool $myBoolean */
private $myBoolean; public $myBoolean = false;
} }

View File

@ -7,6 +7,27 @@ namespace app\Models;
/** /**
* OuterEnum * OuterEnum
*/ */
class OuterEnum { class OuterEnum
{
/**
* Possible values of this enum
*/
const PLACED = 'placed';
const APPROVED = 'approved';
const DELIVERED = 'delivered';
/**
* Gets allowable values of the enum
* @return string[]
*/
public static function getAllowableEnumValues()
{
return [
self::PLACED,
self::APPROVED,
self::DELIVERED
];
}
} }

View File

@ -7,6 +7,27 @@ namespace app\Models;
/** /**
* OuterEnumDefaultValue * OuterEnumDefaultValue
*/ */
class OuterEnumDefaultValue { class OuterEnumDefaultValue
{
/**
* Possible values of this enum
*/
const PLACED = 'placed';
const APPROVED = 'approved';
const DELIVERED = 'delivered';
/**
* Gets allowable values of the enum
* @return string[]
*/
public static function getAllowableEnumValues()
{
return [
self::PLACED,
self::APPROVED,
self::DELIVERED
];
}
} }

View File

@ -7,6 +7,27 @@ namespace app\Models;
/** /**
* OuterEnumInteger * OuterEnumInteger
*/ */
class OuterEnumInteger { class OuterEnumInteger
{
/**
* Possible values of this enum
*/
const NUMBER_0 = 0;
const NUMBER_1 = 1;
const NUMBER_2 = 2;
/**
* Gets allowable values of the enum
* @return string[]
*/
public static function getAllowableEnumValues()
{
return [
self::NUMBER_0,
self::NUMBER_1,
self::NUMBER_2
];
}
} }

View File

@ -7,6 +7,27 @@ namespace app\Models;
/** /**
* OuterEnumIntegerDefaultValue * OuterEnumIntegerDefaultValue
*/ */
class OuterEnumIntegerDefaultValue { class OuterEnumIntegerDefaultValue
{
/**
* Possible values of this enum
*/
const NUMBER_0 = 0;
const NUMBER_1 = 1;
const NUMBER_2 = 2;
/**
* Gets allowable values of the enum
* @return string[]
*/
public static function getAllowableEnumValues()
{
return [
self::NUMBER_0,
self::NUMBER_1,
self::NUMBER_2
];
}
} }

View File

@ -9,7 +9,7 @@ namespace app\Models;
*/ */
class OuterObjectWithEnumProperty { class OuterObjectWithEnumProperty {
/** @var \app\Models\OuterEnumInteger $value */ /** @var int $value */
private $value; public $value = \app\Models\OuterEnumInteger::NUMBER_0;
} }

View File

@ -10,21 +10,21 @@ namespace app\Models;
class Pet { class Pet {
/** @var int $id */ /** @var int $id */
private $id; public $id = 0;
/** @var \app\Models\Category $category */ /** @var \app\Models\Category $category */
private $category; public $category;
/** @var string $name */ /** @var string $name */
private $name; public $name = "";
/** @var string[] $photoUrls */ /** @var string[] $photoUrls */
private $photoUrls; public $photoUrls = [];
/** @var \app\Models\Tag[] $tags */ /** @var \app\Models\Tag[] $tags */
private $tags; public $tags = [];
/** @var string $status pet status in the store*/ /** @var string $status pet status in the store*/
private $status; public $status = "";
} }

View File

@ -10,9 +10,9 @@ namespace app\Models;
class ReadOnlyFirst { class ReadOnlyFirst {
/** @var string $bar */ /** @var string $bar */
private $bar; public $bar = "";
/** @var string $baz */ /** @var string $baz */
private $baz; public $baz = "";
} }

View File

@ -7,6 +7,24 @@ namespace app\Models;
/** /**
* SingleRefType * SingleRefType
*/ */
class SingleRefType { class SingleRefType
{
/**
* Possible values of this enum
*/
const ADMIN = 'admin';
const USER = 'user';
/**
* Gets allowable values of the enum
* @return string[]
*/
public static function getAllowableEnumValues()
{
return [
self::ADMIN,
self::USER
];
}
} }

View File

@ -10,6 +10,6 @@ namespace app\Models;
class SpecialModelName { class SpecialModelName {
/** @var int $specialPropertyName */ /** @var int $specialPropertyName */
private $specialPropertyName; public $specialPropertyName = 0;
} }

View File

@ -10,9 +10,9 @@ namespace app\Models;
class Tag { class Tag {
/** @var int $id */ /** @var int $id */
private $id; public $id = 0;
/** @var string $name */ /** @var string $name */
private $name; public $name = "";
} }

View File

@ -10,27 +10,27 @@ namespace app\Models;
class User { class User {
/** @var int $id */ /** @var int $id */
private $id; public $id = 0;
/** @var string $username */ /** @var string $username */
private $username; public $username = "";
/** @var string $firstName */ /** @var string $firstName */
private $firstName; public $firstName = "";
/** @var string $lastName */ /** @var string $lastName */
private $lastName; public $lastName = "";
/** @var string $email */ /** @var string $email */
private $email; public $email = "";
/** @var string $password */ /** @var string $password */
private $password; public $password = "";
/** @var string $phone */ /** @var string $phone */
private $phone; public $phone = "";
/** @var int $userStatus User Status*/ /** @var int $userStatus User Status*/
private $userStatus; public $userStatus = 0;
} }