Fix ApiExplorer decomposition for [FromHeader] complex parameters - #69141
Draft
snemeckayova wants to merge 3 commits into
Draft
Fix ApiExplorer decomposition for [FromHeader] complex parameters#69141snemeckayova wants to merge 3 commits into
snemeckayova wants to merge 3 commits into
Conversation
snemeckayova
requested review from
a team,
Youssef1313,
cincuranet,
davpetr and
rokonec
as code owners
September 8, 2026 13:25
Contributor
There was a problem hiding this comment.
🟡 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.Headerto 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
marked this pull request as draft
September 8, 2026 13:36
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.
Description
TODO
Fixes #29931