3

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.

Fenton
  • 241,084
  • 71
  • 387
  • 401
  • This code is generated dinamically, maybe the reflection method is calling only directly child from ApiController, im looking here at the source code and will notice you later! – Fals Sep 16 '13 at 14:13
  • Which version of ASP.NET you're using? I did a simples BaseApiController, then included a new one child of the Base and the documentation works! – Fals Sep 16 '13 at 14:34
  • Do you happen to have the attribute called `ApiExplorerSettings` attribute on the base controller? – Kiran Sep 16 '13 at 15:47
  • I'm playing spot the difference at the moment because I have another controller that inherits from the same base controller but appears in the documentation. – Fenton Sep 17 '13 at 07:42

2 Answers2

2

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.

Fenton
  • 241,084
  • 71
  • 387
  • 401
0

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 :)

Toby Simmerling
  • 2,228
  • 1
  • 11
  • 6