Skip to content

Fix ApiExplorer decomposition for [FromHeader] complex parameters - #69141

Draft
snemeckayova wants to merge 3 commits into
mainfrom
snemeckayova/#29931-Fix-from-header-binding
Draft

Fix ApiExplorer decomposition for [FromHeader] complex parameters#69141
snemeckayova wants to merge 3 commits into
mainfrom
snemeckayova/#29931-Fix-from-header-binding

Conversation

@snemeckayova

@snemeckayova snemeckayova commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Description

TODO

Fixes #29931

Copilot AI lite review requested due to automatic review settings September 8, 2026 13:25
@github-actions github-actions Bot added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Sep 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The BindingSource.Header greediness change has broader model-binding implications (not just ApiExplorer) and likely results in [FromHeader] complex parameters binding no data unless additional header value-provider support is added.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This pull request aims to fix ApiExplorer metadata generation for complex parameters annotated with [FromHeader] by allowing property decomposition (so individual header parameters appear instead of a single complex parameter).

Changes:

  • Updated BindingSource.Header to be non-greedy (isGreedy: false) so ApiExplorer can decompose [FromHeader] complex parameters into properties.
  • Added a new complex header DTO and controller action in the ApiExplorer test web site to exercise the scenario.
  • Added a functional regression test asserting ApiExplorer emits individual header parameters for the complex type.
File summaries
File Description
src/Mvc/test/WebSites/ApiExplorerWebSite/Models/HeaderParamsDTO.cs Adds a DTO used to represent a complex type bound from headers in the test site.
src/Mvc/test/WebSites/ApiExplorerWebSite/Controllers/ApiExplorerParametersController.cs Adds an action that binds a complex type from headers to drive ApiExplorer metadata generation.
src/Mvc/test/Mvc.FunctionalTests/ApiExplorerTest.cs Adds a functional regression test validating per-property header parameters are produced by ApiExplorer.
src/Mvc/Mvc.Abstractions/src/ModelBinding/BindingSource.cs Changes BindingSource.Header greediness to enable ApiExplorer decomposition of [FromHeader] complex parameters.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 46 to 50
public static readonly BindingSource Header = new BindingSource(
"Header",
Resources.BindingSource_Header,
isGreedy: true,
isGreedy: false,
isFromRequest: true);
@snemeckayova
snemeckayova marked this pull request as draft September 8, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ApiExplorer handles [FromHeader] binding (on complex type) differently to [FromQuery] binding

2 participants