You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
In the generated classes if an attribute is an enum, in its getter/setter, the phpdoc type is the class that contains the constants with the enum values instead of string:
enum class:
class Enum
{
/** * Possible values of this enum */constFIRST = 'first';
constSECOND = 'second';
As you can see the actual type passed is string and not Enum, so we will get a warning from the IDE.
So the phpdoc of the setter should be:
/** * Sets type, see the accepted values in the Enum class * * @param string|null $type type * * @return self */publicfunctionsetType($type)
{
$this->container['type'] = $type;
return$this;
}
openapi-generator version
5.4.0
The text was updated successfully, but these errors were encountered:
Actually the problem is deeper: when a server sends a response that includes an enum type, the actual string value is still deserialized through json_decode resulting in a null value and finally a class-not-found exception.
IMO enums should never be created as classes/objects/models at least in php 8.0
Actually the problem is deeper: when a server sends a response that includes an enum type, the actual string value is still deserialized through json_decode resulting in a null value and finally a class-not-found exception.
IMO enums should never be created as classes/objects/models at least in php 8.0
I'we just encountered this in a project of mine that uses enums. Where it sets
Bug Report Checklist
Description
In the generated classes if an attribute is an enum, in its getter/setter, the phpdoc type is the class that contains the constants with the enum values instead of string:
enum class:
Attribute setter(Enum type):
Here we set the property:
As you can see the actual type passed is string and not Enum, so we will get a warning from the IDE.
So the phpdoc of the setter should be:
openapi-generator version
5.4.0
The text was updated successfully, but these errors were encountered: