Reputation: 3454
I wanna change company to companies. Is there a way to change this? Without having to rename the controller.
The controller name (above in bold) should remain Company. But in every operation I wanna change it to companies.
The reason I'm not using [Route] is because I have a super class which defines:
[Route("admin/codes/[controller]")]
And the company controller is inheriting from that class. And I want to keep the "admin/codes/" in the url.
What is the best solution here? Without having to rename the controller class.
Upvotes: 0
Views: 3057
Reputation: 2536
Setting the old philosophical singular-plural battle aside, Swagger is a viewport to your API; you shouldn't change a controller name just in Swagger, as the poor souls using your APIs will be rather baffled – they would call /admin/codes/companies
and get a 404 in return, as the MVC framework was not informed of the controller's new name.
What I think you should be looking for is how to change the controller's routing within the MVC framework, and you can do that without changing the super class's routing - for example, using a [RoutePrefix("companies")]
annotation.
Upvotes: 2