This simple demo shows using Microsoft.AspNetCore.Mvc.Versioning
(tutorial) with ASP.NET Core to support multiple versions of an API.
It also uses Swashbuckle (following this tutorial) to provide documentation, which is accessible at https://localhost:5001/swagger
Ensuring that the swagger documentation correctly integrates with the versioning is a little more complex. This example follows the approach of this sample app and docs here.
Build and run with dotnet run
. Access v1 endpoint at https://localhost:5001/weatherforecast
, and v2 at https://localhost:5001/weatherforecast?api-version=2.0