Skip to content

Commit

Permalink
Add unit test to cover description from metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
hwoodiwiss committed Apr 13, 2024
1 parent 232ab16 commit 89f851b
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,30 @@ public void GetSwagger_CanReadEndpointSummaryFromMetadata()
Assert.Equal("A Test Summary", document.Paths["/resource"].Operations[OperationType.Post].Summary);
}

[Fact]
public void GetSwagger_CanReadEndpointDescriptionFromMetadata()
{
var methodInfo = typeof(FakeController).GetMethod(nameof(FakeController.ActionWithParameter));
var actionDescriptor = new ActionDescriptor
{
EndpointMetadata = new List<object>() { new EndpointDescriptionAttribute("A Test Description") },
RouteValues = new Dictionary<string, string>
{
["controller"] = methodInfo.DeclaringType.Name.Replace("Controller", string.Empty)
}
};
var subject = Subject(
apiDescriptions: new[]
{
ApiDescriptionFactory.Create(actionDescriptor, methodInfo, groupName: "v1", httpMethod: "POST", relativePath: "resource"),
}
);

var document = subject.GetSwagger("v1");

Assert.Equal("A Test Description", document.Paths["/resource"].Operations[OperationType.Post].Description);
}

[Fact]
public void GetSwagger_SupportsOption_ConflictingActionsResolver()
{
Expand Down

0 comments on commit 89f851b

Please sign in to comment.