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/