🎸Dynamic OpenAPI Schema Naming Based on DTO Namespace
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- openapi, php
- Domain
- api, backend-api-design
Research direction
Start by reviewing the OpenApiFactory naming strategy and the proposed config location in config/packages/api_platform.yaml. Determine how DTO namespaces and Model context folders would be resolved, then verify that input and output schemas receive the requested EntryPoint.Context.ClassName keys without collisions.
Written by the indexing model from the issue text.
Description
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! 🚀
- Dominant language
- PHP
- Stars
- 2.6k
- Forks
- 989
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 104
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from api-platform/core
-
JSON:API: resource schemas (`*.jsonapi`) have `properties` but no `type: object`Possibly taken @ousamabenyounes claimed this 1 day ago. Open
Difficulty 2/5 Under an hour Newbie friendliness 80/100
api-platform/core#8701 ·
Maintainers usually reply within 1 day
-
JSON:API: `JsonApiCollectionBaseSchemaNoPagination` declares `data` as `type: array` without `items`Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
api-platform/core#8699 ·
Maintainers usually reply within 1 day
-
api:openapi:export --spec-version=3.0.0 outputs `webhooks`, which is invalid in OpenAPI 3.0Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
api-platform/core#8690 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
api-platform/core#8680 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
api-platform/core#8725 ·
Maintainers usually reply within 1 day
All issues in api-platform/core
Similar issues
-
Authentication / Authorization Feature: Volunteer
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 80/100
Maintainers usually reply within 1 day
-
PHP workflow streaming requests buffer the full SSE responsePossibly taken @Winoren claimed this today. Openreview: medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
langgenius/dify#44270 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
bug customer-reported
Difficulty 1/5 Under an hour Newbie friendliness 90/100
MagnaCapax/PMSS#1085 ·
Maintainers usually reply within 5 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day