Skip to content

fix(json-schema): nested gen_id follows the property - #8644

Merged
soyuka merged 1 commit into
api-platform:5.0from
soyuka:fix/json-schema-gen-id-inheritance
Oct 15, 2026
Merged

soyuka merged 1 commit into
api-platform:5.0from
soyuka:fix/json-schema-gen-id-inheritance

Conversation

@soyuka

@soyuka soyuka commented Oct 6, 2026

Copy link
Copy Markdown
Member
Q A
Branch? 5.0
Tickets ∅
License MIT
Doc PR ∅

SchemaFactory built the child context as $serializerContext + ['gen_id' => …], so the first relation's gen_id stuck to every deeper level. The serializer does the opposite (OperationContextTrait): the property's own genId wins and only a null inherits from the parent. With root → a (genId: false) → b (genId: true) the schema named b _noid and used HydraItemBaseSchemaWithoutId while the payload carries @id, and the reverse chain had the mirror problem.

The child context now uses $propertyMetadata->getGenId() ?? ($serializerContext['gen_id'] ?? true).

Found while mapping json-schema for symfony/symfony#64279, related to #8643.

The first relation's gen_id stuck to every deeper embedded definition,
while the serializer lets each property's genId win and only inherits
when it is null. Schemas then advertised `@id` (or not) differently
from the payload.
@soyuka
soyuka merged commit 07babd8 into api-platform:5.0 Oct 15, 2026
115 of 117 checks passed
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