ASP. NET Web API how to automatically generate a help document for annotation, asp. netapi

Source: Internet
Author: User

ASP. NET Web API how to automatically generate a help document for annotation, asp. netapi

ASP. NET Web API generates help documents from comments

By default, ASP. NET Web APIs do not generate help documents from Controller comments. To use annotations as part of the Web API help document, for example, to display the summary in the Description column of the help document, you need to perform some configuration operations.

First, open the properties page of the Web API project in Visual Studio. On the Build settings page, select XML document file and enter the path of the XML file to be generated, for example, App_Data \ OpenAPI. XML.


Then, compile the project to generate an xml file in the corresponding path.

Next, open the Areas \ HelpPage \ App_Start \ HelpPageConfig. cs file, cancel the comments of the config. SetDocumentationProvider code, and modify the path:

Then re-compile and access the/help page to see the effect.

Copy codeThe Code is as follows:
Config. SetDocumentationProvider (new XmlDocumentationProvider (HttpContext. Current. Server. MapPath ("~ /App_Data/OpenAPI. xml ")))

I hope to help you with the above brief introduction.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.