ASP.Net web API Help Page - no content
Asked Answered
D

2

8

I installed the package from NuGet, uncommented the line from HelpPageConfig.cs-

config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml")));

I've set the same file under Properties->Build->XML documentation file, Added a new Global.asax.cs file in which I call for registration for all the areas under Application_Start method:

protected void Application_Start(object sender, EventArgs e)
{
     AreaRegistration.RegisterAllAreas();
}

I've added some summary for some of my controllers:

public class IncidentsController : ApiController
{
     /// <summary>
     /// this is the summary
     /// </summary>
     /// <param name="incidentId">this is incidentId</param>
     /// <returns>it returns something</returns>
     [Route("{incidentId}")]
     [HttpGet]
     public object GetIncidentById(int incidentId)
     {
            return Incidents.SingleOrDefault(i => i.id == incidentId);
     }
}

when i run the webpage and go to '/help' the only thing i see is

ASP.NET Web API Help Page

Introduction

Provide a general description of your APIs here.

and an empty page after that...

I tried to debug that and in HelpController.cs in:

public ActionResult Index()
{
            ViewBag.DocumentationProvider = Configuration.Services.GetDocumentationProvider();
            return View(Configuration.Services.GetApiExplorer().ApiDescriptions);
}

I get no ApiDescriptions.

what am I missing? I'll appreciate any help!

Damico answered 25/8, 2015 at 6:58 Comment(0)
D
13

I was able to solve this by adding GlobalConfiguration.Configure (WebApiConfig.Register); in my Application_Start () method. Because my application uses OWIN I was registering my APIs only in Startup.Configuration (IAppBuilder app).

Dionedionis answered 9/11, 2015 at 18:52 Comment(4)
THANK YOU!! This was my exact problem and your answer solved it for me!Benefaction
You are a Godsend! THANK YOU!!Outrun
Awesome! worked for me too. I was also using OWIN and registering in Startup. THANKS!Hyperplane
if this answer is a little too cryptic please see #18921715Silicate
H
0

Have you mapped you XMl Path right ?

Have you added summary to your methods ? /// /// Gets some very important data from the server. ///

This should help Have you checked WebApi Help Page Description

Hirsch answered 25/8, 2015 at 13:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.