🎸Dynamic OpenAPI Schema Naming Based on DTO Namespace
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 30/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- openapi, php
調査の方向性
まず OpenApiFactory の命名戦略と、config/packages/api_platform.yaml に提案されている設定場所を確認します。DTO の namespace と Model のコンテキストフォルダーがどのように解決されるかを判断し、その後、input スキーマと output スキーマが要求された EntryPoint.Context.ClassName キーを衝突なく受け取ることを確認します。
索引モデルが issue の本文から書いたものです。
説明
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.
ResetPasswordInputin “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
-
OpenAPI schema key should become
ResetPasswordEntryPoint.Request.ResetPasswordInput.jsonld ResetPasswordEntryPoint.Reset.ResetPasswordInput.jsonld -
It should work automatically for any module/feature/folder under
ApiResource/{Module}/{Feature}/Model/{Context}/{DTO}.php. -
No extra configuration (no manual
_api_operation_nameoverrides) or fragile heuristics based on class metadata.
💡 Proposed Solution
Enhance API Platform’s OpenAPI naming strategy to:
-
Extract the resource entrypoint (folder name + “EntryPoint”).
-
Extract the context folder under
Model(e.g.Request,Reset). -
Use the DTO class name.
-
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
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
api-platform/core のほかの issue
-
JSON:API: resource schemas (`*.jsonapi`) have `properties` but no `type: object`対応中かも @ousamabenyounes が 1 日前に担当しました。 オープン
難易度 2/5 1時間未満 初心者へのやさしさ 80/100
api-platform/core#8701 ·
メンテナーはふだん 1 日以内に返信
-
JSON:API: `JsonApiCollectionBaseSchemaNoPagination` declares `data` as `type: array` without `items`オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
api-platform/core#8699 ·
メンテナーはふだん 1 日以内に返信
-
api:openapi:export --spec-version=3.0.0 outputs `webhooks`, which is invalid in OpenAPI 3.0対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
api-platform/core#8690 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
api-platform/core#8680 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
api-platform/core#8725 ·
メンテナーはふだん 1 日以内に返信
api-platform/core の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
メンテナーはふだん 1 日以内に返信
-
PHP workflow streaming requests buffer the full SSE response対応中かも @Winoren が今日担当しました。 オープンreview: medium
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
langgenius/dify#44270 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug customer-reported
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
MagnaCapax/PMSS#1085 ·
メンテナーはふだん 5 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
nunomaduro/collision#375 ·