Segment-based URI versioning puts the API version in a URL path segment, such as `/v1/` or `/v2/`. Different versions can remain available at the same time, helping existing clients keep working when an endpoint changes. The trade-off is more routes and configuration to maintain. section 3.3.3
// ...
builder.Services.AddApiVersioning(options => {
options.ApiVersionReader = new UrlSegmentApiVersionReader(); #1
options.AssumeDefaultVersionWhenUnspecified = true;
options.DefaultApiVersion = new ApiVersion(1, 0);
});
builder.Services.AddVersionedApiExplorer(options => {
options.GroupNameFormat = "'v'VVV"; #2
options.SubstituteApiVersionInUrl = true; #3
});
// ...
Configure ASP.NET Core to read the version from the URL segment. The API explorer groups versions and substitutes the version into generated URLs. section 3.3.3
Give each board-game controller a versioned route such as `v{version:apiVersion}/[controller]`, then mark its supported version with `[ApiVersion("1.0")]` or `[ApiVersion("2.0")]`. Register separate Swagger documents and UI endpoints for v1 and v2 so their routes can be inspected independently. section 3.3.3
