Skip to content

Commit 09c72c5

Browse files
committed
fix(SwaggerGen): include endpoints with unmatching GroupName in OpenAPI document
When an endpoint's GroupName does not match any registered document, treat it as ungrouped and include it in all documents. This fixes the issue where endpoints with WithGroupName() configured would not appear in the OpenAPI document when no corresponding document was registered. Before: GroupName set but not matching docName → endpoint excluded After: GroupName set but not matching any registered doc → included
1 parent d22870e commit 09c72c5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Swashbuckle.AspNetCore.SwaggerGen/SwaggerGenerator/SwaggerGeneratorOptions.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ public SwaggerGeneratorOptions()
8181

8282
private bool DefaultDocInclusionPredicate(string documentName, ApiDescription apiDescription)
8383
{
84-
return apiDescription.GroupName == null || apiDescription.GroupName == documentName;
84+
// If the endpoint's GroupName doesn't match any registered document, treat it as
85+
// ungrouped (include it). This ensures endpoints with a GroupName that's not mapped
86+
// to a specific document are not inadvertently excluded from the OpenAPI document.
87+
return !_options.SwaggerDocs.ContainsKey(apiDescription.GroupName) || apiDescription.GroupName == documentName;
8588
}
8689

8790
private string DefaultOperationIdSelector(ApiDescription apiDescription)

0 commit comments

Comments
 (0)