feat(metadata): resource and operation level itemUriTemplate - #8479
Open
Amoifr wants to merge 1 commit into
Open
feat(metadata): resource and operation level itemUriTemplate#8479Amoifr wants to merge 1 commit into
Amoifr wants to merge 1 commit into
Conversation
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.
Implements the plan laid out in #8075 (comment) (resource + operation
itemUriTemplate), closes #8075.When an item operation has a custom
uriTemplate(new Patch(uriTemplate: '/purchases/{id}/billing-address')), the response@idreuses that URI instead of the canonical one.itemUriTemplateexisted only onPostandGetCollection; this lifts it up:itemUriTemplatemoves toHttpOperation(withgetItemUriTemplate()/withItemUriTemplate()), soGet,PatchandPutaccept it;PostandGetCollectionkeep their signature and delegate.ApiResourcegainsitemUriTemplateas a DRY default; the propagation to operations is automatic through the genericcascadeFromResource()/copyFrom()mechanism, with op-level precedence (op ?? resource ?? null).HttpOperationcarrying anitemUriTemplate, the target operation is resolved throughOperationMetadataFactory::create(). The block is skipped when$context['item_uri_template']was already resolved at the top of the method, which avoids a double resolution through the cascaded template of the target operation (caught by the functional test on op-level precedence).itemUriTemplateat the resource level, and the op-level whitelist acceptsGet,PatchandPut(it threw before); XSD updated.SerializerContextBuilder,OperationContextTraitand the JSON:APIItemNormalizeralready feeditem_uri_templatethroughmethod_exists($operation, 'getItemUriTemplate').Additive, no behavior change when the option is unset. Covered by a unit test on the Symfony
IriConverterand a functional test (CanonicalIriTest) asserting the canonical@idfor a PATCH with a custom URI, both with the resource-level default and with an op-level override taking precedence. The exhaustiveResourceMetadataCompatibilityTestcovers the new resource property through the XML/YAML adapters.