Fix case-insensitive group name matching in OpenAPI document filtering#64353
Merged
captainsafia merged 2 commits intomainfrom Nov 17, 2025
Merged
Fix case-insensitive group name matching in OpenAPI document filtering#64353captainsafia merged 2 commits intomainfrom
captainsafia merged 2 commits intomainfrom
Conversation
Co-authored-by: captainsafia <1857993+captainsafia@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix OpenAPI generation grouping issue with WithGroupName
Fix case-insensitive group name matching in OpenAPI document filtering
Nov 13, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug where OpenAPI document filtering incorrectly excluded endpoints when the casing of .WithGroupName() differed from the document name specified in .AddOpenApi(). Since document names are automatically lowercased during registration, but endpoint group name metadata preserves the original casing, the case-sensitive string comparison caused valid endpoints to be excluded from their documents.
Key Changes:
- Modified the
ShouldIncludepredicate inOpenApiOptionsconstructor to use case-insensitive string comparison - Added test coverage to verify case-insensitive group name matching
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/OpenApi/src/Services/OpenApiOptions.cs | Updated ShouldInclude predicate to use StringComparison.OrdinalIgnoreCase for group name comparison |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiDocumentService/OpenApiDocumentServiceTests.Paths.cs | Added test case verifying case-insensitive matching and added using directive for Microsoft.AspNetCore.OpenApi namespace |
BrennanConroy
approved these changes
Nov 14, 2025
desjoerd
approved these changes
Nov 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix case-insensitive comparison for endpoint group names
Description
OpenAPI document filtering excluded endpoints when
.WithGroupName()casing differed from.AddOpenApi()document name. Since document names are lowercased but endpoint metadata preserves original casing, case-sensitive comparison caused exclusion.Changes:
ShouldIncludepredicate inOpenApiOptionsto useStringComparison.OrdinalIgnoreCaseFixes #64335
Original prompt
This section details on the original issue you should resolve
<issue_title>OpenAPI Generation No Longer Groups Endpoints Using WithGroupName</issue_title>
<issue_description>### Is there an existing issue for this?
Describe the bug
In .NET 9, multiple Open API spec docs could be generated with a specific name utilizing the
.WithGroupNameextension method on either the group itself or particular endpoints. This allowed for a name other than the group's prefix to be used for grouping endpoints into an OpenAPI document that utilized a name other than the group's route prefix.Now, it seems that the OpenAPI generator does not group those endpoints into the related spec document and instead excludes them entirely.
Expected Behavior
I should be able to group endpoints in an OpenAPI Spec document named something other than the Group prefix, utilizing
.WithGroupName("MyGroupName")and.AddOpenApi("MyGroupName").Steps To Reproduce
I have a minimal repro solution that demonstrates the behaviors here:
https://github.com/GoValidate/AspNetCore-Net10-OpenApi-Repro
The OpenApiNet9 and OpenApiNet10 are carbon copies of each other, with one targeting .NET 9 (and the .NET 9 version of AspNetCore OpenAPI) and the other targeting .NET 10 (and the .NET 10 version of AspNetCore OpenAPI). The code in both cases is the same:
New NET 10 Behavior
The following Open API docs are generated in NET 10:
https://localhost:5001/openapi/FirstGroup.json{ "openapi": "3.1.1", "info": { "title": "OpenApiNet10 | firstgroup", "version": "1.0.0" }, "servers": [ { "url": "https://localhost:5001/" } ], "paths": { } }https://localhost:5001/openapi/SecondGroup.json{ "openapi": "3.1.1", "info": { "title": "OpenApiNet10 | secondgroup", "version": "1.0.0" }, "servers": [ { "url": "https://localhost:5001/" } ], "paths": { } }Expected Behavior
In OpenApiNet9, the following swagger docs are generated:
https://localhost:7001/openapi/FirstGroup.json{ "openapi": "3.0.1", "info": { "title": "OpenApiNet9 | FirstGroup", "version": "1.0.0" }, "servers": [ { "url": "https://localhost:7001/" } ], "paths": { "/first-group/explicit": { "get": { "tags": [ "OpenApiNet9" ], "responses": { "200": { "description": "OK", "content": { "text/plain": { "schema": { "type": "string" } } } } } } } }, "components": { }, "tags": [ { "name": "OpenApiNet9" } ] }https://localhost:7001/openapi/SecondGroup.json{ "openapi": "3.0.1", "info": { "title": "OpenApiNet9 | SecondGroup", "version": "1.0.0" }, "servers": [ { "url": "https://localhost:7001/" } ], "paths": { "/second-group/implicit": { "get": { "tags": [ "OpenApiNet9" ], "responses": { "200": { "description": "OK", "content": { "text/plain": { "schema": { "type": "string" } } } } } } } }, "components": { }, "tags": [ { "name": "OpenApiNet9" } ] }Exceptions (if any)
No response
.NET Version
10.0.100
Anything else?
IDE is Rider (though this exhibits with
dotnet run).Output from
dotnet --info