Question

I have a controller that I want to generate documentation for using ASP.NET Web API Help Pages.

When I directly inherit from ApiController the documentation appears:

public class ExampleController : ApiController

But when I inherit from a base controller, it is omitted:

public class ExampleController : ApiBaseController

...

public class ApiBaseController: ApiController

I have switched to delegation rather than inheritance, but I wanted to know how to make it work with inheritance.

Was it helpful?

Solution

Here is a tip I picked up in my experimentation.

The documentation leans heavily on the routes in your API config. If your controller isn't covered by a route, it won't show up. Additionally, the order of the routes in your API config is the order of the operations in your documentation.

To cover both of these points I have created named routes for each controller. This has the added benefit of making each route specific, rather than a single route with lots of optional bits. This ensures all my operations appear in the documentation, in a good order.

I have also added the API tester so the API can be called directly from the documentation.

OTHER TIPS

Check the permissions in your base class. I had the same issue and is was a result of methods that should have been set as internal being protected.

Make sure that all your methods that need to be accessed by the parent item are set to internal and any methods that override the ApiController are set to protected.

Post your code if it still doesn't work.

Works like Gravy :)

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