0

I wanna change company to companies. Is there a way to change this? Without having to rename the controller. enter image description here

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.

enter image description here

What is the best solution here? Without having to rename the controller class.

t0r0X
  • 4,212
  • 1
  • 38
  • 34
Enrico
  • 2,734
  • 1
  • 27
  • 40
  • The whole point of swagger is to expose your Rest api's in a friendly manner to someone who is going to use this. If you show as companies, but the controller has company how will it work?. It doesn't make much sense. isn't it? – pvpkiran Nov 17 '17 at 10:09
  • Let's just assume that I can only change it in the url. Would that be possible? – Enrico Nov 17 '17 at 10:13

1 Answers1

2

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.

MrMister
  • 2,456
  • 21
  • 31