Skip to content

feat!: throw exception when an operation is not declared in ApiResource for parameter attributes on properties - #2346

Open
Maxcastel wants to merge 1 commit into
api-platform:mainfrom
Maxcastel:feat/throw-operation-not-declared-in-ApiResource-for-parameter-attributes-on-properties
Open

Maxcastel wants to merge 1 commit into
api-platform:mainfrom
Maxcastel:feat/throw-operation-not-declared-in-ApiResource-for-parameter-attributes-on-properties

Conversation

@Maxcastel

Copy link
Copy Markdown

Follow-up of the documentation added in #2277 and #2281.

operations on a property-level #[QueryParameter] / #[HeaderParameter] used to accept an operation the resource does not declare: that entry was then silently ignored, while the rest of the list kept working. The example in the filters guide relied on that behaviour, with Patch missing from the resource operations.

api-platform/core#8552 turns it into an error, so the example now documents it instead of presenting it as a supported way to restrict a parameter:

#[ApiResource(
    operations: [
        new GetCollection(),
        new Get(),
    ],
)]
class Book
{
    // Error: Patch is not declared in the resource operations
    #[HeaderParameter(key: 'X-Authorization', operations: [new GetCollection(), new Patch()])]
    public string $authToken = '';
}

Parameter attribute on property "authToken" is restricted to the operation
"ApiPlatform\Metadata\Patch" which is not declared on the resource "App\Entity\Book".

@Maxcastel Maxcastel changed the title feat!: throw exception when an operation is not delared in ApiResourc… feat!: throw exception when an operation is not declared in ApiResource for for parameter attributes on properties Sep 21, 2026
@Maxcastel Maxcastel changed the title feat!: throw exception when an operation is not declared in ApiResource for for parameter attributes on properties feat!: throw exception when an operation is not declared in ApiResource for parameter attributes on properties Sep 21, 2026
@Maxcastel
Maxcastel force-pushed the feat/throw-operation-not-declared-in-ApiResource-for-parameter-attributes-on-properties branch from 4666777 to 8199641 Compare September 21, 2026 13:59

This branch has not been deployed

No deployments
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