Skip to content
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

Support setting operation IDs from EndpointName metadata #2173

Conversation

captainsafia
Copy link
Contributor

@captainsafia captainsafia commented Jul 29, 2021

Fixes #2165.

Part of dotnet/aspnetcore#34514.

// endpoint name if no route name is available. This allows us to
// generate operation IDs for endpoints that are defined using
// minimal APIs.
#if (!NETSTANDARD2_0)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is ifdef'd out since the M.A.Routing 2.1.0 package does not contain the EndpointNameMetadata types that we need here. We could update the repo to rely on M.A.* 2.2.0 packages for everything if we wanted to avoid if-defing here but that seemed more appropriate for a separate PR.

@captainsafia captainsafia marked this pull request as ready for review July 29, 2021 17:01
@bradygaster
Copy link

quick ping to @domaindrivendev. @captainsafia can't apply labels or milestones but this is one of the minimal items we discussed. Thanks!

#if (!NETSTANDARD2_0)
return
actionDescriptor.AttributeRouteInfo?.Name
?? (actionDescriptor.EndpointMetadata.FirstOrDefault(m => m is EndpointNameMetadata) as EndpointNameMetadata)?.EndpointName;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do FirstOrDefault here and not SingleOrDefault because of dotnet/aspnetcore#34199.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DefaultOperationIdSelector should be updated to fallback to EndpointName if AttributeRouteInfo isn't populated
4 participants