[BUG][PHP] settype(): Argument #2 ($type) must be a valid type
Created by: NickUfer
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
The PHP generator sets a field type as mixed when the field can be one of at least 2 types. As seen in the following with value.
protected static $openAPITypes = [
'disabled' => 'bool',
'label' => '\Ory\Kratos\Client\Model\UiText',
'name' => 'string',
'pattern' => 'string',
'required' => 'bool',
'type' => 'string',
'value' => 'mixed', <----- ## HERE ##
'text' => '\Ory\Kratos\Client\Model\UiText',
'src' => 'string',
'href' => 'string',
'title' => '\Ory\Kratos\Client\Model\UiText'
];
Here value can be one of these values.. string, number or boolean -> the generator makes it a mixed:
https://github.com/ory/kratos/blob/e3cf3da357dfbaa64181d7bfbfe42d1f00b6ef7b/.schema/openapi.json#L1080-L1096 https://github.com/ory/kratos/blob/e3cf3da357dfbaa64181d7bfbfe42d1f00b6ef7b/.schema/openapi.json#L1141-L1155
[...]
"value": {
"description": "The input's value.",
"nullable": true,
"oneOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "boolean"
}
]
}
[...]
Later in the generated ObjectSerializer it tries to use settype() for the current data with type mixed, but mixed is not valid for settype() and it never was valid for it either. I don't know how that code came in here. https://www.php.net/manual/en/function.settype.php#refsect1-function.settype-parameters
When he tries to use settype(<value of field 'value'>, 'mixed') it fails with:
settype(): Argument #2 ($type) must be a valid type
Because mixed is not a valid type: https://www.php.net/manual/en/function.settype.php#refsect1-function.settype-parameters
openapi-generator version
5.2.1
OpenAPI declaration file content or url
https://github.com/ory/kratos/blob/master/.schema/openapi.json
Generation Details
Steps to reproduce
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/pull/10576
Suggest a fix
https://github.com/OpenAPITools/openapi-generator/pull/10576