Web API automatically generates help documents and uses Web API test Client Testing

Source: Internet
Author: User

Previously useful in the project to Webapi external interface, found in the project has based on WEBAPI methods and comments automatically generated help documents, can also test Webapi method, the function is very powerful, now take out to share with you.

First look at the generated WEBAPI document.

1, the display is the first page of the build Help document, where values is controller,api The following list shows the requested HTTP method (Get,post, etc.), the requested action, the description of the method.

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

3. Click the test API to open the following page

4, input parameters, click the Send button, open the following page, you can see the return value.

Here are the steps to set up the method:

Development environment VS2012 + MVC4 + WEB API

1. Referencing the web API Test Client through NuGet

References to play the DLL generate the following files:

This is our help. Document interface

2. In the project properties, make the following settings, tick the XML document file, and set the path

3. Create xmldocument.xml under the App_Data folder of the project

4. Open the \areas\helppage\app_start\helppageconfig.cs file and uncomment the following code

Run the project, open Http://localhost:3619/Help, and see the automatically generated API documentation, which is a picture of the 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/

Web API automatically generates help documents and uses Web API test Client Testing

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.