Skip to content

feat(jsonld): operations as schema.org actions - #8877

Merged
soyuka merged 2 commits into
mainfrom
feat/jsonld-potential-action
Nov 27, 2026
Merged

soyuka merged 2 commits into
mainfrom
feat/jsonld-potential-action

Conversation

@dunglas

@dunglas dunglas commented Nov 26, 2026

Copy link
Copy Markdown
Member
Q A
Branch? main
Tickets
License MIT
Doc PR api-platform/docs#...

Adds schema.org potential actions. Operations flagged with extraProperties: ['potential_action' => true] are listed under potentialAction in the JSON-LD representation of their resource: on the item when the operation has URI variables, on the collection otherwise.

#[Post(
    uriTemplate: '/actionable_books/{id}/archive',
    input: ArchiveBookInput::class,
    hydraContext: ['@type' => 'schema:ArchiveAction'],
    extraProperties: ['potential_action' => true],
)]

Each action carries an EntryPoint (urlTemplate, httpMethod, encodingType, contentType) and a <property>-input: required annotation per required writable property. The action type comes from, in order: one action per mapping key for a @type discriminated input, the operation's hydra @type, or a default derived from the HTTP method (CreateAction, ReplaceAction, UpdateAction, DeleteAction). The resource context scopes potentialAction to the schema.org vocabulary.

Test: tests/Functional/JsonLd/PotentialActionTest.php

@soyuka
soyuka marked this pull request as ready for review November 27, 2026 15:57
dunglas and others added 2 commits November 27, 2026 17:26
Operations flagged with extraProperties: ['potential_action' => true] are
listed under potentialAction in the JSON-LD representation of the GET item
(operations with URI variables) or collection (operations without) they
belong to. An @type discriminated input yields one action per mapping key;
other operations use their hydra @type or a default derived from the HTTP
method. Required input properties are annotated with <property>-input.

The resource context scopes potentialAction to the schema.org vocabulary.
Replace the potential_action extra property with a first-class
potentialAction option (bool|string|array) and stop reading the
action type from hydraContext. Nest -input annotations under
result/object when the input is the resource, skip them for
PATCH/DELETE, evaluate operation security, support subresource
collections and forward reset() to the decorated normalizer.
@soyuka
soyuka force-pushed the feat/jsonld-potential-action branch from f5ccbe2 to 9a4c3b4 Compare November 27, 2026 16:26
@soyuka
soyuka merged commit 2d692a6 into main Nov 27, 2026
2 checks passed
@soyuka
soyuka deleted the feat/jsonld-potential-action branch November 27, 2026 16:26
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.

2 participants