I have a WebApi where I need to multi-tenant route versions. This is done easily with a route prefix. Routes v1 & v2 both have controllers A,B,C, and controller C in v2 has a different implementation. This design is in order to break as few consumers as possible.
Swashbuckle seems to behave oddly with this configuration. It errors - due to a swagger spec conflict if I don't include the following code:
c.MultipleApiVersions(apiDesc, version) =>
{
controllers.Add(apiDesc);
var controllerNamespace = apiDesc.ActionDescriptor.ControllerDescriptor.ControllerType.FullName;
if (controllerNamespace.ToLowerInvariant().Contains(version.ToLowerInvariant()))
{
return true;
}
return false;
},
(vc) =>
{
vc.Version("v1", "Quantium.Retail.Hierarchy.Services API v2");
vc.Version("v2", "Quantium.Retail.Hierarchy.Services API v1");
});
This is fine, and makes sense, however only version 1 is passed into the version lamba, so v1 is missing 2 controllers - the two whos code hasn't changed other than the route. The only controller in the docs is the controller that has been re-factored to have slightly different query strings and implementation.
This seems like a pretty commonplace requirement. I need two sets of duplicated routes, separated by version (so [Route("v1/admin"]
on the v1 controller declaration etc. Surely it's supported?
Changing the route on the action method on either controller gives the correct behavior - both routes appear on each version doc. It's as though Swashbuckle only considers the action method route.