[Metadata] Incorrect api schema for path variable
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start at src/Metadata/Resource/Factory/LinkFactory.php, in the public completeLink method, where uriTemplate path variables become Link objects; follow how the linked resource class/property is resolved and how Link schema is consumed when building OpenAPI path parameters. Reproduce with the #[Get('entities/{id}')] example from the issue and inspect the generated OpenAPI/Swagger JSON for the id path parameter. Done means the path parameter schema reflects the property's type/format, covered by tests around LinkFactory or OpenAPI generation; note the maintainer's pending answer on bug-vs-feature and which schema fields to carry over.
索引モデルが issue の本文から書いたものです。
説明
API Platform version(s) affected: 5.0.2
Description
I noticed that all path variables have the default schema ['type' => 'string'], even when the variable is linked to a class property that does have a type / format.
This means that the swagger-ui will display it as a string input field, and miss the correct validation.
How to reproduce
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\Get;
#[Get('entities/{id}')]
readonly class Entity
{
public function __construct(
#[ApiProperty(identifier: true)]
public int $id,
) {
}
}
SwaggerUI
Possible Solution
The ApiPlatform\Metadata\Resource\Factory\LinkFactory class is used to generate Link instances based on things like the Operation's uriTemplate.
Here I can use the propertyMetadataFactory to get the schema of the linked property.
Questions
Is this something that should be fixed/implemented at all? For me this would save me from having to add the uriVariables parameter with Link classes everytime.
Is this considered a bug (pull request towards 5.0 branch), or a missing feature (pull request towards main branch?
- 主要言語
- PHP
- スター
- 2.6k
- フォーク
- 987
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 90
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
api-platform/core のほかの issue
-
DeserializeProvider calls PartialDenormalizationException::getErrors(), deprecated in Symfony 8.1オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
api-platform/core#8650 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
api-platform/core#8649 ·
メンテナーはふだん 1 日以内に返信
-
`OrderExtension` and `OrderFilter` pass string sort directions, deprecated since `doctrine/orm` 3.7対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
api-platform/core#8648 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
api-platform/core#8647 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
api-platform/core#8612 ·
メンテナーはふだん 1 日以内に返信
api-platform/core の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
area:test-harness help wanted priority:low type:chore
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
crazy-goat/php-fpm-ng#913 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
10up/10up-experience#238 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
laravel/nova-issues#7002 ·
-
extension/Commercial needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信