feat!: throw exception when an operation is not declared in ApiResource for parameter attributes on properties - #8552
Open
Maxcastel wants to merge 1 commit into
Conversation
Maxcastel
force-pushed
the
feat/throw-operation-not-declared-in-ApiResource-for-parameter-attributes-on-properties
branch
from
September 21, 2026 13:30
c1bc880 to
162f98e
Compare
Contributor
Author
|
Not sure whether it's better to throw an exception when an operation is listed in a parameter but is not declared on the resource, or to silently ignore it. Proposing this approach just in case. |
Maxcastel
force-pushed
the
feat/throw-operation-not-declared-in-ApiResource-for-parameter-attributes-on-properties
branch
from
September 21, 2026 14:07
162f98e to
8c280f7
Compare
Maxcastel
force-pushed
the
feat/throw-operation-not-declared-in-ApiResource-for-parameter-attributes-on-properties
branch
from
September 21, 2026 14:10
8c280f7 to
8c0bbed
Compare
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.
Follow-up of #7870 and #7899.
#[QueryParameter]/#[HeaderParameter]declared on a property can be restricted to a list of operations. Until now, listing an operation that was not declared in#[ApiResource]was silently ignored: the parameter still applied to the declared operations of the list, and the undeclared one had no effect at all. When none of the listed operations were declared, the parameter simply never applied to anything.#[ApiResource( operations: [ new GetCollection(), new Get(), ], )] class Book { // Before this PR: applied to GetCollection, the Patch entry was silently ignored #[HeaderParameter(key: 'X-Authorization', operations: [new GetCollection(), new Patch()])] public string $authToken = ''; }It now throws a RuntimeException while building the metadata: