Skip to content

feat(metadata)!: collect input and output classes as resources - #8940

Open
soyuka wants to merge 2 commits into
output-resource/1-blank-nodefrom
output-resource/2-collect
Open

soyuka wants to merge 2 commits into
output-resource/1-blank-nodefrom
output-resource/2-collect

Conversation

@soyuka

@soyuka soyuka commented Dec 3, 2026 •

Copy link
Copy Markdown
Member
Q A
Branch? main (6.0, merge after v5.1.0)
Tickets Refs #8849
License MIT
Doc PR api-platform/docs#2321 (to rewrite once the stack lands)

Part 2/6 of the RFC #8849 stack (https://github.com/api-platform/core/stack/8945), review commit by commit: the first commit is the failing test.

input and output classes declared on a resource or its HTTP operations are collected with the resource names: isResourceClass() is true, they are blank node resources with their own short name and /contexts/{ShortName}, they get no route and no identifier from id.

Rules: collected classes match exactly in ResourceClassResolver (no is_a, so subtypes are not resources), interfaces are not collected (they keep today's path, the RFC "concrete only" rule was there because of is_a), an abstract class must carry a DiscriminatorMap, short names must be unique (throws at metadata time). Collection never calls the metadata chain (the resolver is used during the metadata build), it reads the raw declarations; functional tests decorate PhpUnitResourceNameCollectionFactory the same way.

Test: tests/Functional/JsonLd/InputOutputDtoTest.php::testOutputClassIsCollectedAsAResource, unit InputOutputResourceNameCollectionFactoryTest.

BC: output @context is /contexts/X instead of inline, duplicate short names throw, a few fixture DTOs renamed for that reason, ResourceNameCollection cache key bumped.

Classes declared as input or output of a resource or of its HTTP
operations are collected with the resource names: they are blank node
resources with their own short name and JSON-LD context. Collected
classes match exactly (no is_a), interfaces are not collected, abstract
classes need a discriminator map and short names must be unique.

Refs #8849
@soyuka
soyuka added this pull request to stack #8945 December 3, 2026 15:14
@soyuka soyuka changed the title output resource/2 collect feat(metadata)!: collect input and output classes as resources Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant