Fix support for parameter names sourced from attributes (#45572)
Backport of #45572 to release/7.0.
Description
This change resolves an issue where OpenAPI generation via the WithOpenApi method did not factor for the Name argument in parameters sourced from routes or queries via the explicit FromRoute and FromQuery.
Fixes https://github.com/dotnet/aspnetcore/issues/45542
Customer Impact
This bug fix addresses a user-submitted bug report that is presented as a regression from .NET 6. Without this bug fix, users are not able to successfully test endpoints that use explicit binding source attributes with a name via the Swagger UI and the generated OpenAPI document.
Regression?
- [X] Yes
- [ ] No
This is a regression in behavior that was available in .NET 6.
Risk
- [ ] High
- [ ] Medium
- [X] Low
Low risk because this change updates the new OpenAPI package to match the behavior of the existing ApiExplorer implementation.
Verification
- [X] Manual (required)
- [X] Automated
Packaging changes reviewed?
- [ ] Yes
- [ ] No
- [X] N/A
Hi @captainsafia. Please make sure you've updated the PR description to use the Shiproom Template. Also, make sure this PR is not marked as a draft and is ready-to-merge.
To learn more about how to prepare a servicing PR click here.
Hi @captainsafia. Please make sure you've updated the PR description to use the Shiproom Template. Also, make sure this PR is not marked as a draft and is ready-to-merge.
To learn more about how to prepare a servicing PR click here.
Hi @captainsafia. This PR was just approved to be included in the upcoming servicing release. Somebody from the @dotnet/aspnet-build team will get it merged when the branches are open. Until then, please make sure all the CI checks pass and the PR is reviewed.
Approved via email.
@captainsafia were you asking for a merge❔
One QQ on the changes: Don't IFormFile parameters use the name to find a specific attached file❔ I'm not looking at the binder but thought there was something like that…
@captainsafia were you asking for a merge❔
Yep! 😄
One QQ on the changes: Don't
IFormFileparameters use the name to find a specific attached file❔ I'm not looking at the binder but thought there was something like that…
AFAIK, they just use the filename. However, with the OpenAPI specification, form uploads are treated as part of the request body and are documented separately from request parameters (sourced from routes, queries, headers) which support a unique name field. The request body of the OpenAPI schema doesn't support custom names in the same way AFAIK.