Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[Metadata] Incorrect api schema for path variable

オープン
#8,646 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php
領域
api

調査の方向性

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 Image

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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

api-platform/core のほかの issue

api-platform/core の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。