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

🎸Dynamic OpenAPI Schema Naming Based on DTO Namespace

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

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

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
30/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
openapi, php

調査の方向性

まず OpenApiFactory の命名戦略と、config/packages/api_platform.yaml に提案されている設定場所を確認します。DTO の namespace と Model のコンテキストフォルダーがどのように解決されるかを判断し、その後、input スキーマと output スキーマが要求された EntryPoint.Context.ClassName キーを衝突なく受け取ることを確認します。

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

説明

OpenAPI

Feature Request: Dynamic OpenAPI Schema Naming Based on DTO Namespace


📦 Background

By default, API Platform generates OpenAPI schemas using the “short name” of each DTO, which often leads to collisions and unclear schema names when multiple operations share the same class name (e.g. ResetPasswordInput). We have a custom decorator today that post-processes the OpenAPI components and renames schemas at runtime to {EntryPoint}.{Context}.{DTO}, but this requires complex workarounds and still depends on heuristics or introspection of generated schema names.


🚩 Problem
  • Schema collisions when different operations share DTO class names (e.g. ResetPasswordInput in “request” and “perform” flows).

  • Lack of clarity: consumers see only the short class name, not the context (“Request” vs “Reset”) nor the entrypoint.

  • Complex custom decorators required to hack around built‑in naming logic.


🎯 Desired Behavior

When you define DTOs under a folder structure like:

src/ApiResource/
└── Auth
    └── ResetPassword
        ├── Model
        │   ├── Request
        │   │   └── ResetPasswordInput.php
        │   └── Reset
        │       └── ResetPasswordInput.php
        └── ResetPasswordEntryPoint.php
  1. OpenAPI schema key should become

    ResetPasswordEntryPoint.Request.ResetPasswordInput.jsonld
    ResetPasswordEntryPoint.Reset.ResetPasswordInput.jsonld
    
  2. It should work automatically for any module/feature/folder under ApiResource/{Module}/{Feature}/Model/{Context}/{DTO}.php.

  3. No extra configuration (no manual _api_operation_name overrides) or fragile heuristics based on class metadata.


💡 Proposed Solution

Enhance API Platform’s OpenAPI naming strategy to:

  1. Extract the resource entrypoint (folder name + “EntryPoint”).

  2. Extract the context folder under Model (e.g. Request, Reset).

  3. Use the DTO class name.

  4. Compose the OpenAPI schema key as {EntryPoint}.{Context}.{ClassName}, automatically for all input/output DTOs.

This could live inside the core OpenApiFactory or as a first‑class feature behind a config flag, e.g.:

# config/packages/api_platform.yaml
api_platform:
  openapi:
    dynamic_schema_naming: true

Benefits:

  • Eliminates custom decorator hacks.

  • Prevents name collisions entirely.

  • Provides clear, self‑documenting schema names.


🔧 Example Before/After
Before After
components.schemas.ResetPasswordInput.jsonld components.schemas.ResetPasswordEntryPoint.Request.ResetPasswordInput
components.schemas.ResetPasswordInput_1.jsonld components.schemas.ResetPasswordEntryPoint.Reset.ResetPasswordInput

Please consider adding this as an official enhancement to API Platform’s OpenAPI generator. It aligns with the directory‑based organization of DTOs and greatly improves developer experience and schema clarity.
Thank you! 🚀

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

環境構築

はじめの一歩

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

api-platform/core のほかの issue

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

似ている issue

PHP の issue をもっと見る

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

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