Skip to content

7.0.0 Preview 2

Pre-release
Pre-release
Compare
Choose a tag to compare
@commonsensesoftware commonsensesoftware released this 17 Nov 04:47
· 141 commits to main since this release

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

  • Use 404 over 400 when versioning only by URL segment (#911)

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.