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
When using a generic type: "object" in my swagger file for a property and then setting that property such as:
$my_data = new \stdClass();
$my_data->hi = "world";
$client->setMyField($my_data);
The generator throws an error saying "no function ::getFormatters" because it is attempting to run that static function on the generic PHP standard class, which does not exist.
Swagger-codegen version
Version 2.3
Swagger declaration file content or url
{
"definitions": {
"Example": {
"description": "This is an example for nested objects.",
"properties": {
"mapping_data": {
"type": "object",
"description": "Mapping data as an object"
}
}
}
}
}
I was going to create a patch when I had a chance.
We should also include a guard against circular references; at the same time, maybe we just let the stack overflow and leave that issue to the developer.
The text was updated successfully, but these errors were encountered:
Site note, maybe someone finds this useful:
I have a similar problem where serializing a member that has an stdClass on it results in the error
Call to undefined method stdClass::swaggerFormats()
As a workaround i fixed it by adding this snippet in the beginning of sanitizeForSerialization
if ($datainstanceof \stdClass) {
$data = get_object_vars($data);
}
I think thats more or less doing the same like your solution. Im struggeling a bit with understanding in what cases swagger-codegen will create assoc-arrays and when it will create stdClasses.
Description
When using a generic
type: "object"
in my swagger file for a property and then setting that property such as:The generator throws an error saying "no function ::getFormatters" because it is attempting to run that static function on the generic PHP standard class, which does not exist.
Swagger-codegen version
Version 2.3
Swagger declaration file content or url
Command line used for generation
java -jar swagger-codegen.jar generate -l php -o output-dir -i swagger.json
Steps to reproduce
Just run the swagger generator for
php
Suggest a fix/enhancement
In
ObjectSerialization#sanitizeForSerialization
add this section aboveis_object
check.I was going to create a patch when I had a chance.
We should also include a guard against circular references; at the same time, maybe we just let the stack overflow and leave that issue to the developer.
The text was updated successfully, but these errors were encountered: