api-platform / api-platform/schema-generator

Serializer groups on property no longer supported

未关闭
#404 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
PHP
星标
474
派生
107
PR 合并指标
30 天内没有已合并 PR

描述

**API Platform version(s) affected**: 3.1.6 (Schema-generator version 5.2.0)

**Description**

The `groups` parameter no longer generates `Groups` 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`. A `Person` has one property `email`. The normalization context of the post collection endpoint for `Referral` has the serialization group set to "referral:post:write" (this works as expected). The `email` property on `Person` has the `groups` option set to `referral:post:write` such that a person entity can be created from the `Referral` collection post resource.
```
types:
Referral:
guessFrom: Referral
properties:
person: {range: Person, cardinality: (*..1)}
operations:
Get:
normalizationContext:
groups: [referral:item:read]
GetCollection:
normalizationContext:
groups: [referral:collection:read]
Post:
denormalizationContext:
groups: [referral:post:write]
normalizationContext:
groups: [referral:post:read]
Person:
properties:
email:
range: https://schema.org/Email
required: true
groups:
- referral:post:write
```
Outcome:
When generating this schema, the `groups` option on `Person` 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 through `ApiPlatform\SchemaGenerator\AttributeGenerator\SerializerGroupsAttributeGenerator`. This functionality seems like it's no longer available, though it's still referenced in the documentation.
**Possible Solution**

It 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 remove `groups` from the list of supported options in the documentation, and code.

Ideally the functionality would be added back into the current version.

**Additional Context**

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。