How to implement drilldown grouping in swagger?

22 Views Asked by At

I want to implement drilldown grouping in swagger for now I have grouping by relative path and I need to add drilldown grouping by controller name. there any way to do it? Using asp.net web api 2(asp.net 4.7 framework,not core) and Swagger.Net, Version=8.5.10.302

this is my swagger configuration:

public class SwaggerConfig
{
    public static void Register()
    {
        var thisAssembly = typeof(SwaggerConfig).Assembly;
    
        GlobalConfiguration.Configuration
            .EnableSwagger("swagger/docs/{apiVersion}", config =>
            {
                config.IgnoreObsoleteActions();
                config.IgnoreObsoleteProperties();
                config.UseFullTypeNameInSchemaIds();  
                config.MultipleApiVersions(SelectTargetApi, (vc) =>
                    {
                        vc.Version("v1", " APIs v1");
                        vc.Version("v2", " APIs v2");
                    });

                config.GroupActionsBy(apiDesc =>
                    {
                        if (apiDesc.RelativePath.ToLower().StartsWith("app"))
                            return "App apis";
                        if (apiDesc.RelativePath.ToLower().StartsWith("admin"))
                            return "Admin apis";
                        if (apiDesc.RelativePath.ToLower().StartsWith("ecommerce"))
                            return "Ecommerce apis";
                        if (apiDesc.RelativePath.ToLower().StartsWith("external"))
                            return "External apis";
                        if (apiDesc.RelativePath.ToLower().StartsWith("magic"))
                            return "Magic apis";
                            return "Other";
                        });
    
            config.OperationFilter<RemoveControllerNameInOperationIdFilter>();
                        config.OperationFilter<AuthorizationHeaderParameterOperationFilter>();
                        config.OperationFilter<ComplexObjectParameterNameFilter>();
                        config.DescribeAllEnumsAsStrings();
    
                        config.DocumentFilter<CustomDocumentFilter>();
                        config.IncludeXmlComments(System.AppDomain.CurrentDomain.BaseDirectory + @"\App_Data\Api.xml");
                        config.IncludeXmlComments(System.AppDomain.CurrentDomain.BaseDirectory + @"\App_Data\ApiModels.xml");
    
                    })
                    .EnableSwaggerUi(config =>
                    {
                     
                        if (Common.IsProduction())
                        {
                            config.InjectStylesheet(thisAssembly, "Api.Content.CustomSwaggerStyle.css");
                           config.InjectJavaScript(thisAssembly, "Api.Scripts.swagger-custom.js");
                        }
                        config.DocExpansion(DocExpansion.None);
                        config.EnableDiscoveryUrlSelector();
                       
                    });
            }
        }

actions enter image description here

0

There are 0 best solutions below