Skip to content

Commit b789e7e

Browse files
Chris Martinezcommonsensesoftware
Chris Martinez
authored andcommitted
Refactor MapApiGroup to NewVersionedApi (from ASP.NET team feedback)
1 parent 26f80e5 commit b789e7e

File tree

8 files changed

+15
-15
lines changed

8 files changed

+15
-15
lines changed

examples/AspNetCore/WebApi/MinimalApiExample/Program.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
1818
};
1919

20-
var forecast = app.MapApiGroup();
20+
var forecast = app.NewVersionedApi();
2121

2222
// GET /weatherforecast?api-version=1.0
2323
forecast.MapGet( "/weatherforecast", () =>

examples/AspNetCore/WebApi/MinimalOpenApiExample/Program.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747

4848
// Configure the HTTP request pipeline.
4949
var app = builder.Build();
50-
var orders = app.MapApiGroup( "Orders" );
51-
var people = app.MapApiGroup( "People" );
50+
var orders = app.NewVersionedApi( "Orders" );
51+
var people = app.NewVersionedApi( "People" );
5252

5353
// 1.0
5454
var ordersV1 = orders.MapGroup( "/api/orders" )

src/AspNetCore/WebApi/src/Asp.Versioning.Http/Builder/IEndpointConventionBuilderExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ private static void AddMetadata( EndpointBuilder builder, object item )
444444
CultureInfo.CurrentCulture,
445445
SR.NoVersionSet,
446446
builder.DisplayName,
447-
nameof( IEndpointRouteBuilderExtensions.MapApiGroup ),
447+
nameof( IEndpointRouteBuilderExtensions.NewVersionedApi ),
448448
nameof( IEndpointRouteBuilderExtensions.WithApiVersionSet ) ) );
449449
}
450450

src/AspNetCore/WebApi/src/Asp.Versioning.Http/Builder/IEndpointRouteBuilderExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static class IEndpointRouteBuilderExtensions
6969
/// <param name="builder">The extended <see cref="IEndpointRouteBuilder"/>.</param>
7070
/// <param name="name">The optional name associated with the builder.</param>
7171
/// <returns>A new <see cref="IVersionedEndpointRouteBuilder"/> instance.</returns>
72-
public static IVersionedEndpointRouteBuilder MapApiGroup( this IEndpointRouteBuilder builder, string? name = default )
72+
public static IVersionedEndpointRouteBuilder NewVersionedApi( this IEndpointRouteBuilder builder, string? name = default )
7373
{
7474
if ( builder is null )
7575
{

src/AspNetCore/WebApi/src/Asp.Versioning.Http/SR.Designer.cs

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/AspNetCore/WebApi/src/Asp.Versioning.Http/SR.resx

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
<value>An API version is required, but was not specified.</value>
122122
</data>
123123
<data name="CannotNestApiGroup" xml:space="preserve">
124-
<value>An API group cannot be mapped as a nested group.</value>
124+
<value>A versioned API group cannot be mapped as a nested group.</value>
125125
</data>
126126
<data name="CannotNestVersionSet" xml:space="preserve">
127127
<value>A grouped API version set cannot be nested under another group.</value>

src/AspNetCore/WebApi/test/Asp.Versioning.Http.Tests/Builder/IEndpointConventionBuilderExtensionsTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public void with_api_version_set_should_not_override_existing_metadata()
289289

290290
var app = builder.Build();
291291
var versionSet = new ApiVersionSetBuilder( default ).Build();
292-
var group = app.MapApiGroup();
292+
var group = app.NewVersionedApi();
293293
var get = group.MapGet( "/", () => Results.Ok() );
294294
IEndpointRouteBuilder endpoints = app;
295295

src/AspNetCore/WebApi/test/Asp.Versioning.Http.Tests/Builder/IEndpointRouteBuilderExtensionsTest.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void with_api_version_set_should_not_allow_nesting()
7272
}
7373

7474
[Fact]
75-
public void map_api_group_should_not_be_allowed_multiple_times()
75+
public void new_versioned_api_should_not_be_allowed_multiple_times()
7676
{
7777
// arrange
7878
var builder = WebApplication.CreateBuilder();
@@ -84,14 +84,14 @@ public void map_api_group_should_not_be_allowed_multiple_times()
8484
var app = builder.Build();
8585

8686
// act
87-
var mapApiGroup = () => app.MapApiGroup().MapApiGroup();
87+
var newVersionedApi = () => app.NewVersionedApi().NewVersionedApi();
8888

8989
// assert
90-
mapApiGroup.Should().Throw<InvalidOperationException>();
90+
newVersionedApi.Should().Throw<InvalidOperationException>();
9191
}
9292

9393
[Fact]
94-
public void map_api_group_should_not_allow_nesting()
94+
public void new_versioned_api_should_not_allow_nesting()
9595
{
9696
// arrange
9797
var builder = WebApplication.CreateBuilder();
@@ -101,13 +101,13 @@ public void map_api_group_should_not_allow_nesting()
101101
services.AddApiVersioning();
102102

103103
var app = builder.Build();
104-
var g1 = app.MapApiGroup();
104+
var g1 = app.NewVersionedApi();
105105
var g2 = g1.MapGroup( "Test" );
106106

107107
// act
108-
var mapApiGroup = () => g2.MapApiGroup();
108+
var newVersionedApi = () => g2.NewVersionedApi();
109109

110110
// assert
111-
mapApiGroup.Should().Throw<InvalidOperationException>();
111+
newVersionedApi.Should().Throw<InvalidOperationException>();
112112
}
113113
}

0 commit comments

Comments
 (0)