Open calls9-tylersmith opened 1 year ago
Indeed, groups
has been replaced by attributes
. Could you make a PR to update the documentation?
It is done by AttributeGenerator, however USE imports are missing in the generated classes. Can anybody fix it? Or should I create PR (Im using this generator for the first time, it might take the time).
EDIT: I was able to fix it using following configuration
uses:
Groups:
name: Symfony\Component\Serializer\Annotation\Groups
API Platform version(s) affected: 3.1.6 (Schema-generator version 5.2.0)
Description
The
groups
parameter no longer generatesGroups
attribute for properties as stated in the documentation.How to reproduce
The below config (excess removed) describes a referral resource that has one property
person
. APerson
has one propertyemail
. The normalization context of the post collection endpoint forReferral
has the serialization group set to "referral:post:write" (this works as expected). Theemail
property onPerson
has thegroups
option set toreferral:post:write
such that a person entity can be created from theReferral
collection post resource.Outcome: When generating this schema, the
groups
option onPerson
is ignored. Looking through the code, it looks like the option is defined, but never used. This functionality used to work in version 4.0.1 throughApiPlatform\SchemaGenerator\AttributeGenerator\SerializerGroupsAttributeGenerator
. This functionality seems like it's no longer available, though it's still referenced in the documentation. Possible SolutionIt is possible to set the Groups attribute using the
attributes
option, but this is a workaround. In this case it would still be necessary to at least removegroups
from the list of supported options in the documentation, and code.Ideally the functionality would be added back into the current version.
Additional Context