Search code examples
asp.net-web-apiasp.net-web-api-helppages

How to make WebApi HelpPage recognize model documentations located outside the WebApi project itself


Let's say I have two project in one solution

  • WebApi: A WebApi project that provides access points for all api services
  • Core: A library project where business Logic defined here, including system model.

For each WebApi request, it uses ModelState to check if the model was valid and then pass the request to the business model defined in the Core library to get result.

I wanted to have automatic API documentation so I configured the WebApi project to generate XML document and the HelpPage module did perfectly as expected, except when it comes to models that's defined in the Core.dll, it's left blank.

I wonder if there's any workaround that could make the HelpPage module "recognize" XML documentations outside the WebApi project?


Solution

  • For each external library that contains documentation, you can setup a post build event that copies the locally generated xml file to a central "documentation" folder. This would obviously require that each project that is generating xml docs to uniquely name the file.

    Your web api project can then run a post build event to copy whichever xml files it needs from the central shared library into its own project folder. You then need to tweak the xml documentation provider to look for multiple xml files as shown in this post

    How can Xml Documentation for Web Api include documentation from beyond the main project?