In my ASP.NET Web Api (ASP.NET 4 MVC 5) application I have two routes configured like so:
// Default route. Comes "out of the box" with Web Api.
// e.g. api/users/123
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
// A route for child controllers. See for example the LockController
// that is "nested" under the "UsersController".
// e.g. api/users/123/lock
config.Routes.MapHttpRoute(
name: "ChildApi",
routeTemplate: "api/{parentController}/{parentId}/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
These actually work quite well in that I have a "top level" UsersController
that is matched by the first route and a "child" LockController
(in a Users
folder) that is matched by the second route.
Now that I've added Swashbuckle 5 (Swagger for .net) to my application, Swagger is confused into showing both routes for each method I've implemented. For example:
So Swagger recognizes the LockController
as both a top-level controller and a child controller.
How can I tell Swagger that a particular controller is top-level or child?
Additionally, can I make swagger recognize that the path to the lock resource, for example, is /api/users/{id}/lock
and not /api/{parentController}/{parentId}/lock
as Swagger is currently showing?