Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions RestApi.Test/V1/ExampleTest.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text.Json;
using System.Threading.Tasks;
using NUnit.Framework;
using RestApi.Models.V1;
using RestApi.Api.V1.Models;
using RestApi.Test.Models;

namespace RestApi.Test.V1
Expand Down
2 changes: 1 addition & 1 deletion RestApi.Test/V2/ExampleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Text.Json;
using System.Threading.Tasks;
using NUnit.Framework;
using RestApi.Models.V2;
using RestApi.Api.V2.Models;
using RestApi.Test.Models;

namespace RestApi.Test.V2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Microsoft.AspNetCore.Mvc;
using NSwag.Annotations;

namespace RestApi.Controllers
namespace RestApi.Api.Common.Controllers
{
[ApiController]
[ApiVersion("1")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using RestApi.Models.V1;
using NSwag.Annotations;
using RestApi.Api.V1.Models;

namespace RestApi.Controllers.V1
namespace RestApi.Api.V1.Controllers
{
// Version is determined by Namespace Convention, which is set up in Startup.cs
// See more details about the convention in https://github.com/microsoft/aspnet-api-versioning/wiki/API-Version-Conventions

[ApiController]
[ApiVersion("1")]
[Route("api/v{version:apiVersion}/[controller]")]
[OpenApiTag("API Example: Weather Forecast")]
public partial class ExampleController : ControllerBase
{
private static readonly string[] Summaries = new[]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Text.Json.Serialization;

namespace RestApi.Models.V1
namespace RestApi.Api.V1.Models
{
public class WeatherForecast
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using RestApi.Models.V2;
using NSwag.Annotations;
using RestApi.Api.V2.Models;

namespace RestApi.Controllers.V2
namespace RestApi.Api.V2.Controllers
{
// Version is determined by Namespace Convention, which is set up in Startup.cs
// See more details about the convention in https://github.com/microsoft/aspnet-api-versioning/wiki/API-Version-Conventions

[ApiController]
[ApiVersion("2")]
[Route("api/v{version:apiVersion}/[controller]")]
[OpenApiTag("API Example: Weather Forecast")]
public partial class ExampleController : ControllerBase
{
private static readonly string[] Areas = new[]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Text.Json.Serialization;

namespace RestApi.Models.V2
namespace RestApi.Api.V2.Models
{
public class WeatherForecast
{
Expand Down
2 changes: 2 additions & 0 deletions RestApi/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Versioning.Conventions;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
Expand All @@ -21,6 +22,7 @@ public void ConfigureServices(IServiceCollection services)

services.AddApiVersioning(options =>
{
options.Conventions.Add(new VersionByNamespaceConvention());
options.ReportApiVersions = true;
});

Expand Down