WebApi Help Page Description

What fills the description of the Webapi method on the sub page and introduction paragraph?

enter image description here

+53
asp.net-mvc asp.net-web-api
Jun 18 '14 at 11:31
source share
3 answers

According to this article, you can use XML documentation comments to create documentation. To enable this feature, open Areas / HelpPage / App_Start / HelpPageConfig.cs and uncomment the following line:

 config.SetDocumentationProvider(new XmlDocumentationProvider( HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml"))); 

Now include the XML documentation. In Solution Explorer, right-click the project and select Properties. Select the Create page.

In the Exit section, check the XML documentation file. In the edit box, enter "App_Data / XmlDocument.xml".

Add some comments on controller methods. For example:

 /// <summary> /// Gets some very important data from the server. /// </summary> public IEnumerable<string> Get() { return new string[] { "value1", "value2" }; } /// <summary> /// Looks up some data by ID. /// </summary> /// <param name="id">The ID of the data.</param> public string Get(int id) { return "value"; } 
+82
Jun 18 '14 at 11:56
source share

To view the description, you must follow this:

  1. Every action in your client controller must have XML documentation
  2. Open the properties of the project that contains your controllers and enable XML documentation as follows: enter image description here
  3. In the Register method for the HelpPageConfig class (Areas / HelpPage / App_Start / HelpPageConfig.cs), uncomment line 19 and remember to change the file path as follows:

     config.SetDocumentationProvider(new XmlDocumentationProvider( HttpContext.Current.Server.MapPath("~/App_Data/MvcApplication4.XML")) ); 

That is all you have to do. The last thing to do is to include the file created in App_Data in your project so that the file can be deployed to work.

+40
Jun 18 '14 at 11:55
source share

For those of you who use VB.NET, you seem to have to do it a little differently.

Click the Compilation tab (there is no Build tab) for the Web API project, and then make sure the Create XML Documentation File check box is selected .

enter image description here

The output is actually placed in / bin / enjprojectName automotive.xml , so now you need to change the call to SetDocumentationProvider so that it points to the path " ~ / bin / {projectname} .xml " (obviously, replace {project_name} with the real name of the project).

This seems smelly, so please let me know if anyone finds another way to do this.

0
Aug 09 '19 at 12:28
source share



All Articles