Wrong Serializer Groups import in Symfony User documentation
まだ誰も着手していません。
評価
- 難易度
- 1/5
- 見積もり時間
- 1時間未満
- 初心者へのやさしさ
- 85/100
- issue の種類
- ドキュメント
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- php, symfony
調査の方向性
リポジトリ内のユーザードキュメントファイルを見つけます(おそらく docs/core/user-guide/ などにあります)。Groups の import 文を探します。'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
- フォーク
- 982
- 平均マージ
- 1日 16時間
- マージ済み PR(30日)
- 59
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
api-platform/core のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
api-platform/core#8571 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
api-platform/core#8564 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
api-platform/core#8495 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
api-platform/core#8471 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
api-platform/core#8475 ·
api-platform/core の issue をすべて見る
似ている issue
-
Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
Automattic/safe-publish#594 ·
-
needs-triage Platform(Default)
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
HttpClient
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
symfony/symfony-docs#23092 ·
-
sync-en
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
sync-en
難易度 1/5 1時間未満 初心者へのやさしさ 95/100