Skip to content

Commit

Permalink
Use MapApiGroup name when used WithOpenApi. Fixes #920
Browse files Browse the repository at this point in the history
  • Loading branch information
commonsensesoftware committed Nov 26, 2022
1 parent 8bf2581 commit 3b85f84
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,11 @@ private static void AddMetadata( EndpointBuilder builder, ApiVersionSet versionS
}

metadata.Add( versionSet );

if ( !string.IsNullOrEmpty( versionSet.Name ) )
{
metadata.Insert( 0, new TagsAttribute( versionSet.Name ) );
}
}

private static void AddMetadata( EndpointBuilder builder, object item )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace Microsoft.AspNetCore.Builder;

using Asp.Versioning;
using Asp.Versioning.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using System.Runtime.CompilerServices;
Expand Down Expand Up @@ -52,6 +53,11 @@ public static class IEndpointRouteBuilderExtensions
throw new InvalidOperationException( SR.CannotNestVersionSet );
}

if ( !string.IsNullOrEmpty( name ) )
{
builder.Add( endpoint => endpoint.Metadata.Insert( 0, new TagsAttribute( name ) ) );
}

builder.Finally( EndpointBuilderFinalizer.FinalizeRoutes );

return builder.NewVersionedEndpointRouteBuilder( builder, builder, name );
Expand All @@ -78,6 +84,11 @@ public static class IEndpointRouteBuilderExtensions
var group = builder.MapGroup( string.Empty );
IEndpointConventionBuilder convention = group;

if ( !string.IsNullOrEmpty( name ) )
{
convention.Add( endpoint => endpoint.Metadata.Insert( 0, new TagsAttribute( name ) ) );
}

convention.Finally( EndpointBuilderFinalizer.FinalizeRoutes );

return builder.NewVersionedEndpointRouteBuilder( group, group, name );
Expand Down

0 comments on commit 3b85f84

Please sign in to comment.