Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ private ApiDescription CreateApiDescription(RouteEndpoint routeEndpoint, string
RelativePath = routeEndpoint.RoutePattern.RawText?.TrimStart('/'),
ActionDescriptor = new ActionDescriptor
{
DisplayName = routeEndpoint.DisplayName,
RouteValues =
{
["controller"] = controllerName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,19 @@ public void AddsMultipleParameters()
Assert.Equal(BindingSource.Body, fromBodyParam.Source);
}

[Fact]
public void AddsDisplayNameFromRouteEndpoint()
{
var apiDescription = GetApiDescription(() => "foo", displayName: "FOO");

Assert.Equal("FOO", apiDescription.ActionDescriptor.DisplayName);
}

private IList<ApiDescription> GetApiDescriptions(
Delegate action,
string pattern = null,
IEnumerable<string> httpMethods = null)
IEnumerable<string> httpMethods = null,
string displayName = null)
{
var methodInfo = action.Method;
var attributes = methodInfo.GetCustomAttributes();
Expand All @@ -316,7 +325,7 @@ private IList<ApiDescription> GetApiDescriptions(
var endpointMetadata = new EndpointMetadataCollection(metadataItems.ToArray());
var routePattern = RoutePatternFactory.Parse(pattern ?? "/");

var endpoint = new RouteEndpoint(httpContext => Task.CompletedTask, routePattern, 0, endpointMetadata, null);
var endpoint = new RouteEndpoint(httpContext => Task.CompletedTask, routePattern, 0, endpointMetadata, displayName);
var endpointDataSource = new DefaultEndpointDataSource(endpoint);
var hostEnvironment = new HostEnvironment
{
Expand All @@ -331,8 +340,8 @@ private IList<ApiDescription> GetApiDescriptions(
return context.Results;
}

private ApiDescription GetApiDescription(Delegate action, string pattern = null) =>
Assert.Single(GetApiDescriptions(action, pattern));
private ApiDescription GetApiDescription(Delegate action, string pattern = null, string displayName = null) =>
Assert.Single(GetApiDescriptions(action, pattern, displayName: displayName));

private static void TestAction()
{
Expand Down