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
Description
If object is part of the correct serialization group, but nested object doesn't have this group assigned, nested object is serialized as empty array. Instead, I would expect exception to be thrown or null returned instead of array
How to reproduce
Given code
classFoo {
public __construct(#[Groups('groupA')] publicBar$bar) {}
}
classBar {
public __construct (#[Groups('groupB')] public string $baz) {};
}
And return new Foo(new Bar('baz')); with groupA as serialization group, APIP will serialize it like so {"foo": {"bar": []}}. Instead, I expect it will serialize it like {"foo": {"bar": null}}, since serializing this as array breaks OpenAPI contract
Possible Solution
Throw exception, or return null
The text was updated successfully, but these errors were encountered:
API Platform version(s) affected: 3.2.18
Description
If object is part of the correct serialization group, but nested object doesn't have this group assigned, nested object is serialized as empty array. Instead, I would expect exception to be thrown or
null
returned instead ofarray
How to reproduce
Given code
And return
new Foo(new Bar('baz'));
withgroupA
as serialization group, APIP will serialize it like so{"foo": {"bar": []}}
. Instead, I expect it will serialize it like{"foo": {"bar": null}}
, since serializing this as array breaks OpenAPI contractPossible Solution
Throw exception, or return
null
The text was updated successfully, but these errors were encountered: