Create a versioned and documented ASP.NET Core Web API
ReviewCoreASPHosting.NET | Best and cheap ASP.NET Core 1.0 hosting. Let’s create a versioned and semi-automatically documented Web API, this could be done both for public API, and quite useful for, internal-use API’s as well.The ASP.NET Core Web API Project
Create a new project Visual C# > .NET Core > ASP.NET Core Web Application and give a descriptive name to your API.
We’re going to add three NuGet packages:Install-Package Microsoft.AspNetCore.Mvc.Versioning
Install-Package Swashbuckle.AspNetCore -Pre
Install-Package SwashbuckleAspNetVersioningShim -Pre
Two of these packages are prerelease packages but they are fully functional
You can now remove the automatically created ValuesController.cs and let’s add a new HelloController.csusing Microsoft.AspNetCore.Mvc;namespace VersionedWebApi.Controllers
{
/// <summary>
/// HelloController, just saying Hello World!
/// </summary>
[ApiVersion("1.0", Deprecated = true)]
[Route("api/v{version:apiVersion}/[controller]")]
public class HelloController : Controller
{
/// <summary>
/// Default Get call returning Hello World!
...