fullstackhero / dotnet-starter-kit

Production Grade Cloud-Ready .NET 8 Starter Kit (Web API + Blazor Client) with Multitenancy Support, and Clean/Modular Architecture that saves roughly 200+ Development Hours! All Batteries Included.

Home Page:https://fullstackhero.net/dotnet-webapi-boilerplate/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] ApiVersioning is not working

serkanmendi opened this issue · comments

I created a new brand controller and put it under the v2 folder.
I wrote the following code and when swagger runs I get an error
Am I making a mistake?

[ApiVersion("2.0")]
public class BrandsController : VersionedApiController
{
[MapToApiVersion("2.0")]
[HttpPost("search")]
[MustHavePermission(FSHAction.Search, FSHResource.Brands)]
[OpenApiOperation("Search brands using available filters.", "")]
public Task<PaginationResponse> SearchAsync(SearchBrandsRequest request)
{
return Mediator.Send(request);
}
}

result error : The method 'get' on path '/api/tenants' is registered multiple times.

I guess your code and your error are not linked.
Your code is about a post request and your error about a get request.
I think :

  • you have to make a search in your code with "api/tenants" and you will find almost two get resquests with that route.
  • you need to have just one route registred with "api/tenants"

I opened a new project and added a new brandcontroller under the Host/Catalog/v2.

this code
namespace FSH.Starter.Host.Controllers.V2;
[ApiVersion("2.0")]
public class BrandsController : VersionedApiController
{
[MapToApiVersion("2.0")]
[HttpPost("search")]
[MustHavePermission(FSHAction.Search, FSHResource.Brands)]
[OpenApiOperation("Search brands using available filters.", "")]
public Task<PaginationResponse> SearchAsync(SearchBrandsRequest request)
{
return Mediator.Send(request);
}
}

API Versioning will change with V2 Release.