aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

Fix support for parameter names sourced from attributes (#45572)

Open captainsafia opened this issue 3 years ago • 1 comments

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

captainsafia avatar Dec 14 '22 18:12 captainsafia

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.

ghost avatar Dec 14 '22 18:12 ghost

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.

ghost avatar Jan 06 '23 22:01 ghost

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.

ghost avatar Jan 07 '23 01:01 ghost

Approved via email.

captainsafia avatar Jan 07 '23 01:01 captainsafia

@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…

dougbu avatar Jan 07 '23 01:01 dougbu

@captainsafia were you asking for a merge❔

Yep! 😄

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…

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.

captainsafia avatar Jan 10 '23 00:01 captainsafia