Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] ApiVersioning is not working #900

Open
serkanmendi opened this issue Nov 16, 2023 · 2 comments
Open

[BUG] ApiVersioning is not working #900

serkanmendi opened this issue Nov 16, 2023 · 2 comments

Comments

@serkanmendi
Copy link

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.

@fcantenot
Copy link

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"

@serkanmendi
Copy link
Author

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);
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants