Wrong Serializer Groups import in Symfony User documentation
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 1/5
- 预计耗时
- 1 小时以内
- 新手友好度
- 85/100
- Issue 类型
- 文档
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
调研方向
在代码仓库中找到用户文档文件(可能在 docs/core/user-guide/ 或类似目录中)。找到 Groups 的导入语句。将 'Annotation\Groups' 改为 'Attribute\Groups'。通过检查文档是否正确构建来验证更改,并确保没有其他相关导入需要更新。
由索引模型根据 Issue 内容生成。
描述
The Symfony User documentation uses the following import for serialization groups:
use Symfony\Component\Serializer\Annotation\Groups;
With API Platform 5.0 and Symfony 8.1, this does not work as shown in the documentation.
The correct import is:
use Symfony\Component\Serializer\Attribute\Groups;
I noticed this because debug:serializer App\Entity\User showed empty serialization groups for all properties when using Annotation\Groups.
After changing the import to Attribute\Groups and clearing the Symfony cache, the serialization groups were correctly detected and the documented user creation endpoint worked as expected.
Environment
API Platform: 5.0
Symfony: 8.1
PHP: 8.4
Expected behavior
The serialization groups shown in the documentation should be recognized when following the example with a current Symfony version.
Actual behavior
Using Symfony\Component\Serializer\Annotation\Groups results in the groups not being recognized by the serializer.
debug:serializer App\Entity\User reports:
email groups => []
plainPassword groups => []
This subsequently causes the documented POST /api/users operation to fail validation because email and plainPassword are not denormalized.
Suggested fix
Update the example to use:
use Symfony\Component\Serializer\Attribute\Groups;
The current serialization documentation already indicates that Symfony 7+ uses attributes, so the User documentation appears to be inconsistent with this.
- 主要语言
- PHP
- 星标
- 2.6k
- 派生
- 989
- 平均合并
- 1 天 19 小时
- 30 天内合并 PR
- 87
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
api-platform/core 的其他 Issue
-
SkolemIriConverter isn't reset between requests in worker mode (missing kernel.reset tag)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 1/5 1 小时以内 新手友好度 85/100
api-platform/core#8680 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 54/100
api-platform/core#8664 · 1 条评论 ·
维护者通常 1 天内回复
-
[Metadata] Incorrect api schema for path variable可能已有人在做 @bram123 于 2 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 68/100
api-platform/core#8646 · 1 条评论 ·
维护者通常 1 天内回复
-
DenormalizationViolationFactory crash when GroupSequence is used可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 3/5 1-2 天 新手友好度 64/100
api-platform/core#8639 ·
维护者通常 1 天内回复
-
HTTP cache purgers error handling and performance issues可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 4/5 3-5 天 新手友好度 38/100
api-platform/core#8591 ·
维护者通常 1 天内回复
查看 api-platform/core 的全部 Issue
相似的 Issue
-
feature request
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
Automattic/blocks-engine#2803 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
hestiacp/hestiacp#5798 · 2 条评论 ·
维护者通常 1 天内回复
-
Bug Component: HTTP Component: Telemetry
难度 2/5 1-3 小时 新手友好度 74/100
-
难度 2/5 1-3 小时 新手友好度 62/100
woocommerce/woocommerce-google-analytics-integration#699 ·
维护者通常 1 天内回复