New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Endpoint name metadata should be set automatically to the method name when Map
overload is called passing a MethodGroup
#34540
Comments
Thanks for contacting us. We're moving this issue to the |
@rafikiassumaniMSFT was this done? The PR I knew about is still in draft #35069 |
@DamianEdwards I learned today that we might not be able to do this at the moment due to the behavior implications in MVC. @javiercn @pranavkm @davidfowl . I am happy to re-open the issue and discuss further next week. |
Yep -- I think that would be helpful. I was OOF last week so would be good to get context on the reasoning behind this. I know @javiercn had posted a comment in the PR around have duplicate |
I think the fact that local function names are mangled makes this less attractive. If we can make that work somehow then we can revisit... |
Here's what I did in my playground app to enable this: https://github.com/DamianEdwards/MinimalApiPlayground/blob/main/src/MinimalApiPlayground/Properties/OpenApi.cs#L137 Fair warning, it assumes the format of compiler-generated method names and uses |
Endpoint names are used to lookup endpoints when generating links using
LinkGenerator
, and as their unique per application are a good candidate for using as theoperationId
for an endpoint in OpenAPI (Swagger) documents.(domaindrivendev/Swashbuckle.AspNetCore#2165 is tracking setting the operationId from endpoint name by default in Swashbuckle.)
Endpoint names are set using the Microsoft.AspNetCore.Routing.IEndpointNameMetadata interface. In the framework today this can be set imperatively by adding an instance of Microsoft.AspNetCore.Routing.EndpointNameMetadata to the endpoint's metadata, e.g. builder.WithMetadata(new EndpointNameMetadata("GetTodoById")). Issues #34538 and #34539 are tracking providing further ways to define endpoint names manually.
In minimal APIs we should automatically set the endpoint name to the value of
MethodInfo.Name
when the endpoint is defined using aMethodGroup
rather than a lambda or anonymous delegate, e.g.:The text was updated successfully, but these errors were encountered: