dotnet-starter-kit icon indicating copy to clipboard operation
dotnet-starter-kit copied to clipboard

[BUG] ApiVersioning is not working

Open serkanmendi opened this issue 2 years ago • 2 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<BrandDto>> SearchAsync(SearchBrandsRequest request) { return Mediator.Send(request); } }

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

serkanmendi avatar Nov 16 '23 18:11 serkanmendi

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"

fcantenot avatar Nov 17 '23 08:11 fcantenot

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<BrandDto>> SearchAsync(SearchBrandsRequest request) { return Mediator.Send(request); } }

serkanmendi avatar Nov 17 '23 08:11 serkanmendi

API Versioning will change with V2 Release.

iammukeshm avatar Jun 02 '24 20:06 iammukeshm