1
0
mirror of https://github.com/ncblakely/GiantsTools synced 2024-11-21 13:45:37 +01:00

Add API versioning.

This commit is contained in:
Nick Blakely 2020-10-12 14:42:44 -07:00
parent 0a8271c7df
commit eb4f555606
6 changed files with 11 additions and 0 deletions

View File

@ -5,6 +5,7 @@
using Microsoft.AspNetCore.Mvc;
[ApiController]
[ApiVersion("1.0")]
[Route("api/[controller]")]
public class CommunityController : ControllerBase
{

View File

@ -12,6 +12,7 @@
using Microsoft.Extensions.Logging;
[ApiController]
[ApiVersion("1.0")]
[Route("api/[controller]")]
public class CrashReportsController : ControllerBase
{

View File

@ -13,6 +13,7 @@ using Microsoft.Extensions.Logging;
namespace Giants.Web.Controllers
{
[ApiController]
[ApiVersion("1.0")]
[Route("api/[controller]")]
public class ServersController : ControllerBase
{

View File

@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc;
namespace Giants.WebApi.Controllers
{
[ApiController]
[ApiVersion("1.0")]
[Route("api/[controller]")]
public class VersionController : ControllerBase
{

View File

@ -12,6 +12,7 @@
<ItemGroup>
<PackageReference Include="AutoMapper" Version="10.0.0" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.14.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="4.1.1" />
<PackageReference Include="NSwag.AspNetCore" Version="13.7.0" />
</ItemGroup>

View File

@ -2,6 +2,7 @@ using AutoMapper;
using Giants.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@ -23,6 +24,11 @@ namespace Giants.Web
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddApiVersioning(config =>
{
config.DefaultApiVersion = new ApiVersion(1, 0);
config.AssumeDefaultVersionWhenUnspecified = true;
});
services.AddOpenApiDocument();