Home
Atom Feed

Released ASP.NET WebApi documentation site generator

Generating good documentation has always been a hassle.

I have just released a package that will make that process much easier!
Imagine having an automated documentation site that uses your standard xml comments to create easy-to-use human readable documentation pages.

We all love documented API's. But making a nice, understandable UI for the documentation has always been a barrier.
In WebAPI RC, Microsoft added an api for retreiving documentation for ApiControllers.

This NuGet package will automatically generate a documentation site for your ASP.NET WebApi controllers.
It uses the xml documentation on your code to generate a human readable page for your API consumers.

The package lets you turn this:

 

Into this!

It even supports the AttributeRouting package for generating route documentation!

Currently it supports the following xml elements:

  • summary
  • remarks
  • example
  • returns

How to set up

First you need to make your API assembly to create a documentation xml file.
You can do this by going to the Properties window for your API project and click the "Build" pane.
Then just check the "XML documentation file" checkbox under the "Output" header. 

Then you need to wire up the documentation provider.

If you use Ninject, just download the WebApi.DocumentationController.Ninject NuGet package and then you're all set.

Otherwise, you need to use a dependency resolver to bind

WebApi.DocumentationController.DocumentationProviders.XmlCommentDocumentationProvider

to the interface

System.Web.Http.Description.IDocumentationProvider

By default, the XmlCommentDocumentationProvider will look for an xml file named after the main website assembly (which should be your WebAPI assembly). 
I.e. If your assembly is named "MyAssembly.dll", then the provider will look for a file named "MyAssembly.xml".
You can also specify a separate file by supplying the "documentPath" constructor argument.

It is possible edit the layout and the styling as you see fit.
The relevant files are located in /Content/documentation, /Views/Help.

How to use

Enter the url to your website and append "/help". You will the open the documentation site and can browse the documentation.

Download on NuGet

Fork on GitHub