Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

7.0.0 Preview 2 #916

Locked Unanswered
commonsensesoftware asked this question in Q&A
Discussion options

This is the second and likely final preview release for ASP.NET Core with .NET 7.0 support. No additional work is planned, but there are some breaking changes that can be tried, tested, and discussed before promoting to the official release.

Features

ASP.NET Core

  • Added MapApiGroup() as a shortcut for MapGroup( "" ).WithApiVersionSet()
  • Metadata can now be added to groups (e.g. RouteGroupBuilder)
  • Added injectable VersionedEndpointRouteBuilderFactory delegate

In Preview 2, metadata can now be applied even more succinctly.

var builder = WebApplication.CreateBuilder( args );
builder.Services.AddApiVersioning();
var app = builder.Build();
var orders = app.MapApiGroup(); // ← api group with optional name
var v1 = orders.MapGroup( "/api/order" ).HasApiVersion( 1.0 ); // ← all endpoints in this group have 1.0
var v2 = orders.MapGroup( "/api/order" ).HasApiVersion( 2.0 ); // ← all endpoints in this group have 2.0
v1.MapGet( "/{id:int}", ( int id ) => new V1.Order() { Id = id, Customer = "John Doe" } );
v2.MapGet( "/{id:int}", ( int id ) => new V2.Order() { Id = id, Customer = "John Doe", Phone = "555-555-5555" } );
v2.MapDelete( "/{id:int}", ( int id ) => Results.NoContent() );

All of the previous methods of configuring metadata are still supported. For more examples, refer to the:

Fixes

Breaking Changes

The following are breaking changes from Preview 1. If you haven't added any customizations, these should all be source code compatible.

  • Add group metadata validation to avoid common developer mistakes
  • Replace IApiVersionSetBuilderFactory interface with injectable ApiVersionSetBuilderFactory delegate
  • Refactor RouteHandlerBuidler extensions into IEndpointRouteBuilderExtensions
    • This allows adding metadata on an endpoint or route group

If you have additional input or feedback, please provide them in the discussion. This will likely be the last time to discuss it before the release becomes official.


This discussion was created from the release 7.0.0 Preview 2.
You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /