Created
June 4, 2020 16:53
-
-
Save gavilanch/680f859091d5c57b977d52e9595afc8b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GroupingByNamespaceConvention : IControllerModelConvention | |
{ | |
public void Apply(ControllerModel controller) | |
{ | |
var controllerNamespace = controller.ControllerType.Namespace; | |
var apiVersion = controllerNamespace.Split(".").Last().ToLower(); | |
if (!apiVersion.StartsWith("v")) { apiVersion = "v1"; } | |
controller.ApiExplorer.GroupName = apiVersion; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment