Web API man pages are always empty
I've added Nuget help pages to generate documentation for my web API, but it doesn't work for me, no API methods are shown.
I am an uninhibited line:
config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml")));
I checked the box in the XML documentation file and set the path to App_Data/XmlDocument.xml
I am not using Glimpse as many solutions here write about it.
I even installed nuget package for authorization help pages but that doesn't help
What's wrong with that? If I run an empty project than it works, but this API is too big to start over.
source to share
If you are using OWIN as middleware (like me), you can initialize a new one HttpConfiguration
inside its startup method. The problem is that HelpController
both HelpPageConfig
are used GlobalConfiguration.Configuration
, which seems to be wrong. What helped me:
Step 1: run the start HttpConfiguration
static field
[assembly: OwinStartup(typeof(MyProject.API.Startup))]
namespace MyProject.API
{
public class Startup
{
//new
public static HttpConfiguration HttpCfg;
//
public void Configuration(IAppBuilder app)
{
HttpCfg = new HttpConfiguration();
WebApiConfig.Register(HttpCfg);
app.UseWebApi(HttpCfg);
AreaRegistration.RegisterAllAreas();
}
}
}
Step 2: go to HelpPageAreaRegistration
and edit a method RegisterArea
like this
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"HelpPage_Default",
"Help/{action}/{apiId}",
new { controller = "Help", action = "Index", apiId = UrlParameter.Optional });
//old
//HelpPageConfig.Register(GlobalConfiguration.Configuration);
//new
HelpPageConfig.Register(Startup.HttpCfg);
}
Step 3: go to HelpController
and edit the standard constructor like this
//old
//public HelpController() : this(GlobalConfiguration.Configuration){ }
//new
public HelpController() : this(Startup.HttpCfg){ }
I hope this helps and not too late;)
source to share