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
2 changes: 1 addition & 1 deletion src/OpenApi/src/Services/OpenApiOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public sealed class OpenApiOptions
/// </summary>
public OpenApiOptions()
{
ShouldInclude = (description) => description.GroupName == null || description.GroupName == DocumentName;
ShouldInclude = (description) => description.GroupName == null || string.Equals(description.GroupName, DocumentName, StringComparison.OrdinalIgnoreCase);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Net.Http;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.OpenApi;
using Microsoft.AspNetCore.Routing;

public partial class OpenApiDocumentServiceTests : OpenApiDocumentServiceTestBase
Expand Down Expand Up @@ -67,6 +68,31 @@ await VerifyOpenApiDocument(builder, document =>
});
}

[Fact]
public async Task GetOpenApiPaths_RespectsShouldInclude_CaseInsensitive()
{
// Arrange
var builder = CreateBuilder();
var openApiOptions = new OpenApiOptions { DocumentName = "firstgroup" };

// Act
builder.MapGet("/api/todos", () => { }).WithMetadata(new EndpointGroupNameAttribute("FirstGroup"));
builder.MapGet("/api/users", () => { }).WithMetadata(new EndpointGroupNameAttribute("SecondGroup"));

// Assert -- The default `ShouldInclude` implementation should include endpoints that
// match the document name case-insensitively. The document name is "firstgroup" (lowercase)
// but the endpoint group name is "FirstGroup" (mixed case), and it should still match.
await VerifyOpenApiDocument(builder, openApiOptions, document =>
{
Assert.Collection(document.Paths.OrderBy(p => p.Key),
path =>
{
Assert.Equal("/api/todos", path.Key);
}
);
});
}

[Fact]
public async Task GetOpenApiPaths_RespectsSamePaths()
{
Expand Down
Loading