Question

How can I avoid the Help page showing both versions of my method?

As you can see, I've set up a custom route for /api/property/search/{finnId}, but I don't want the one using query parameters to show up in the Help page. Any way to get around this? I'm using the built in Help page from the ASP.NET Fall 2012 BUILD preview.

Btw, don't worry about the fact that it says POST, I've since switched it to GET, but I get the same results.

Was it helpful?

Solution

If you're simply looking to hide this route in the Help page and not actually disable it in the app, you could always tweak the logic in the display template.

You could modify the "...\DisplayTemplates\ApiGroup.cshtml" file by adding logic to look at each api that's going to be rendered and decide whether or not you want to include it based on the presence of a query string in the URL.

Still, the important thing to note is that this does not disable the route. You're just hiding it on this Help page. If you want to disable the route, I think you'll need to define your own custom routes.

OTHER TIPS

As there are different combinations of route request for Api, help page by default shows all combination.If we just want to hide the display on the UI, we could remove the items from collection in HelpController.cs

//helpcontroller.cs 
        public ActionResult Index()
        {
            ViewBag.DocumentationProvider = Configuration.Services.GetDocumentationProvider();
            //return View(Configuration.Services.GetApiExplorer().ApiDescriptions); 
            var apiExplorer = Configuration.Services.GetApiExplorer();
            for (int i = apiExplorer.ApiDescriptions.Count - 1; i >= 0; i--)
            {
                if (apiExplorer.ApiDescriptions[i].RelativePath.Contains("?")) { apiExplorer.ApiDescriptions.RemoveAt(i); }
            }
            return View(apiExplorer.ApiDescriptions);
        }

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top