Skip to content

fix(metadata): operation parameters take precedence over parameter attributes on properties - #8623

Open
Maxcastel wants to merge 2 commits into
api-platform:5.0from
Maxcastel:fix/parameter-attributes-precedence
Open

Maxcastel wants to merge 2 commits into
api-platform:5.0from
Maxcastel:fix/parameter-attributes-precedence

Conversation

@Maxcastel

@Maxcastel Maxcastel commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor
Q A
Branch? 5.0
Tickets n/a
License MIT
Doc PR n/a

A parameter attribute declared on a property replaces the parameter with the same key explicitly declared on the operation, so it is impossible to customize it for one operation. Everywhere else the most specific declaration wins (resource/global parameters, defaults.parameters).

Before

#[ApiResource(operations: [
    new GetCollection(parameters: ['name' => new QueryParameter(description: 'From operation', required: false)]),
    new Get(),
])]
class Book
{
    #[QueryParameter(description: 'From property', required: true)]
    public string $name = '';
}

GetCollection gets the property parameter (required: true, "From property"): the operation declaration is lost.

After

GetCollection keeps its own parameter (required: false, "From operation"); Get still gets the property parameter.

@Maxcastel Maxcastel changed the title Fix/parameter attributes precedence fix(metadata): operation parameters take precedence over parameter attributes on properties Oct 1, 2026
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