The Web API automatically generates help documentation and uses the Web API Test Client for testing. apitest

Source: Internet
Author: User

The Web API automatically generates help documentation and uses the Web API Test Client for testing. apitest

Previously, webapi was used in the project to provide external interfaces. In the project, it was found that the help documentation was automatically generated based on webapi methods and annotations, And the webapi method can be tested, which is very powerful, I will share it with you.

Take a look at the generated webapi documentation.

1. Generate the help document homepage, where Values is the controller. The list below the API shows the request http method (Get, POST, etc.), request action, method description.

 

2. Click the link in the red box to open the api method details page, as shown in,

3. Click Test API to open the following page:

4. Enter parameters and click Send to open the following page. The returned values are displayed.

The procedure is as follows:

Development Environment VS2012 + MVC4 + WEB API

1. Use NuGet to reference the Web API Test Client

When referencing the DLL, the following files are generated:

Here is our help Document Interface

2. Set the following settings in the project properties, check the XMl document file, and set the path

 

3. Create XmlDocument. xml in the App_Data folder of the project.

4. Open the \ Areas \ HelpPage \ App_Start \ HelpPageConfig. cs file and cancel the following code comments.

 

 

Run the project and open http: // localhost: 3619/Help to view the automatically generated api document, which is an image of this article.

Click to download the project code

Reference: http://www.c-sharpcorner.com/UploadFile/2b481f/adding-the-test-api-in-the-Asp-Net-web-api-help-page/

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.