asp.net how the Web API automatically generates annotations for help documents _ practical Tips

Source: Internet
Author: User
Tags comments

asp.net Web APIs generate help documents from annotations

By default, the ASP.net Web API does not generate help documents from controller comments. If you want to use annotations as part of a Web API help document, such as displaying summary in a method annotation in the description column of a Help document, you need to make some configuration actions.

First open the Properties page for the Web API project in Visual Studio, on the Build Settings page, select XML document file, and enter the path to place the XML file that will be generated, such as App_data\openapi.xml.


The project is then compiled, and the XML file is generated under the corresponding path.

Then open the Areas\helppage\app_start\helppageconfig.cs file and cancel config. Setdocumentationprovider code comments, modify the path:

Then recompile, access the/help page, you can see the effect.

Copy Code code as follows:

Config. Setdocumentationprovider (New Xmldocumentationprovider (HttpContext.Current.Server.MapPath) ("~/app_data/ Openapi.xml "))

Through the above simple introduction, I hope to help you

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.