Document `#[NotExposed]` for nested DTOs in design.md and dto.md
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- php
- Domain
- documentation
Research direction
Read core/dto.md and core/design.md, then compare the existing NotExposed reference in core/jsonapi.md. Add the requested explanation, PHP example, and cross-link; done means users can discover how nested DTO metadata is documented without exposing public endpoints.
Written by the indexing model from the issue text.
Description
Context
#[NotExposed] is currently documented only in jsonapi.md (for JSON:API relations) and briefly mentioned in openapi.md. It is missing from the two pages most users land on when designing DTOs:
Problem
API Platform's metadata pipeline (Hydra docs, OpenAPI, JSON Schema, property security, etc.) walks #[ApiResource] classes only. Nested POPOs referenced via property typehints are invisible to the doc generators. Users hit this repeatedly (e.g. https://github.com/api-platform/core/issues/8187, https://github.com/api-platform/core/issues/8087) and the typical answer — "mark the nested DTO with #[NotExposed]" — is not discoverable from the DTO docs.
Suggested addition
Short subsection in dto.md (and a mention in design.md) covering:
- Nested DTOs referenced from an output DTO are not introspected for docs unless they are themselves resources
- Use
#[NotExposed]on a nested DTO to register its metadata (Hydra/OpenAPI/property factories) without exposing public endpoints - Brief example:
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\NotExposed;
#[ApiResource(operations: [new Get(/* ... */)])]
class Response
{
/** @var Nested[] */
public array $data = [];
}
#[NotExposed]
class Nested
{
public function __construct(public int $id) {}
}
- Cross-link to the existing
NotExposedreference injsonapi.md
- Dominant language
- No language data
- Stars
- 181
- Forks
- 1.1k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 24
Contributor 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/docs
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
api-platform/docs#2318 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
api-platform/docs#2310 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
api-platform/docs#2280 · 2 comments ·
-
Needs Work
Difficulty 4/5 3-5 days Newbie friendliness 35/100
api-platform/docs#2133 · 9 comments · 1 reaction ·
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 58/100
api-platform/docs#1450 · 2 comments ·
All issues in api-platform/docs
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·