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

OpenAPI missing request schema when providing MediaType examples

クローズ
#8,661 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
openapi, php
領域
api

調査の方向性

Start by reproducing with the EntityResource class and the POST operation's custom openapi RequestBody from the issue, then inspect the generated OpenAPI output for that request body. The bug is that providing MediaType examples drops the schema, so the first question is where the custom MediaType replaces the generated one. Done when the request body keeps the resource schema alongside the examples, and the maintainers have settled whether the merge approach proposed in the issue is acceptable.

索引モデルが issue の本文から書いたものです。

説明

API Platform version(s) affected: 5.0.2

Description
Documenting requestBody examples removes the request format schemas

How to reproduce
Using the following ApiResource class:


#[Post(
    status: 201,
    openapi: new Operation(
        requestBody: new RequestBody(
            content: new ArrayObject(
                [
                    'application/ld+json' => new MediaType(
                        examples: new ArrayObject(
                            [
                                'hello world' => new Example(description: 'Submitting a "hello world" entity', value: new EntityResource(1, 'Hello world')),
                                'foo bar'     => new Example(description: 'Submitting a "foo bar" entity', value: new EntityResource(2, 'Foo bar')),
                            ],
                        ),
                    ),
                ],
            ),
        ),
    ),
)]
readonly class EntityResource
{
    public function __construct(#[ApiProperty(identifier: true)] public int $id, public string $name)
    {
    }
}

The schema is missing from the generated spec:

SwaggerUI output Image

And I have to add it myself, but this risks documentation drift caused by future API updates.

new ArrayObject(
    [
        'type'       => 'object',
        'properties' => new ArrayObject(
            [
                'id'   => new ArrayObject(['type' => 'integer']),
                'name' => new ArrayObject(['type' => 'string']),
            ],
        ),
    ],
),
SwaggerUI output Image Image

Additional
Would it be possible/okay to merge the API-Platform generated MediaType with the APIResource's MediaType? And only fill in the null values?

主要言語
PHP
スター
2.6k
フォーク
989
平均マージ
1日 19時間
マージ済み PR(30日)
87

環境構築

はじめの一歩

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

api-platform/core のほかの issue

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

似ている issue

PHP の issue をもっと見る

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

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