Repository navigation
feat(hydra)!: classify custom actions by extraProperties.custom_action only - #23
Merged
Merged
Conversation
Boots FrameworkBundle, ApiPlatformBundle and this bundle in a test kernel with an unconnected in-memory EntityManager, so the Hydra documentation can be asserted end to end without a database. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The URI heuristic lived in CustomOperationHydraFactory and as a copy in
HydraDocumentationSubscriber. Both now call Metadata\CustomAction. No
behaviour change: the one observable difference between the copies
({._format} as a whole path segment) is kept per call site and pinned by
characterization tests.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…/docs.jsonld [*] HydraDocumentationSubscriber matched a documented operation to the first metadata operation with the same HTTP method and placeholder flag, so two item or two collection operations of one resource shared one URL and a POST with a placeholder got the collection URL. Operations are now paired by position, mirroring DocumentationNormalizer::getHydraOperations(): per ApiResource, in getOperations() order, hidden ones left out, POST and collection operations on the Entrypoint, the rest on the class. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…n only [*]
A custom action is exactly the HTTP operation whose merged
extraProperties carry custom_action with the boolean true. The URI
heuristic is removed from CustomOperationHydraFactory and
HydraDocumentationSubscriber, with no fallback. NotExposed stubs are
never custom actions, even when they inherit a resource marker. The
factory strips {._format} from its URL carrier and adds none when the
author set @id or hydra:uriTemplate.
BREAKING CHANGE: operations are no longer typed schema:Action by their
URI shape. Set extraProperties: ['custom_action' => true] on every real
action; unmarked operations get API Platform's own type and title.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
README gets a section on custom actions and no longer describes path shapes as the criterion in the hydra:operation section. Config info texts, the services.yaml comment and the comments in AddHydraOperationsSubscriber follow; the info texts of the two enabled switches say that they currently have no effect. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A custom action in the Hydra documentation is now exactly the operation whose merged
extraPropertiescarrycustom_action: true(boolean). The URI heuristic is removed from both places that used it,CustomOperationHydraFactoryandHydraDocumentationSubscriber, with no fallback. Release0.8.0.Breaking: real actions lose
@type: schema:Actionuntil their resource sets the marker. Clients that build an actions menu from that type show nothing for them, without an error. See CHANGELOG and the new README section "Custom actions".Commits
test: first kernel test setup; boots API Platform plus the bundle and serves/api/docs.jsonld(no database, no new dependencies).refactor: the heuristic moves intoMetadata\CustomAction, used by factory and subscriber. No behaviour change, pinned by characterization tests.fix:HydraDocumentationSubscriberpairs each documented operation with its metadata operation by position (mirroringDocumentationNormalizer::getHydraOperations()) instead of "first operation with the same method and placeholder flag", so every operation carries its own URL.feat!: marker instead of heuristic.NotExposedis never a custom action. The factory strips{._format}from its URL carrier and adds none when the author set one.docs: README, configinfo()texts, comments.docs(changelog):0.8.0.Marker semantics
truemarks; missing,false,1,'true','1'do not.#[ApiResource]overapi_platform.defaults.extra_properties;falseon an operation exempts it.hydraContextstill wins.hydra:titlestill comes from the operation name (see the comment on CustomOperationHydraFactory misclassifies reads on multi-segment resource paths #8).Tests
252 tests, 772 assertions (was 85 / 213). Each regression test fails against the commit before its fix:
GETs of one resource sharing one URL,POSTwith a placeholder getting the collection URL./a,/a/{id},/a/b,/a/b/{id},/a/b/verbwith and without marker forGETandPOSTat both places, marker values, inheritance from resource and global defaults,NotExposed.Run locally on PHP 8.5 with API Platform 4.4.10; inheritance is not verified for API Platform
^3.0.Not in this PR
Closes #7
Closes #8
🤖 Generated with Claude Code