SwaggerUI ASP. Net WebAPI2, swaggeruiwebapi2

Source: Internet
Author: User

SwaggerUI ASP. Net WebAPI2, swaggeruiwebapi2

ASP. NET WebAPI2 is used for background interface development. When testing with the front-end, a demo is always required to be sent to him. However, this is very troublesome and he may not be able to remember it.

Then we thought about SwaggerUI to generate a test document.

Let's take a look at its specific usage!

Step 1:

Open the package management console in VS2015 (which is your own tool) and enter:

Install-Package Swashbuckle

Wait for the installation. After the installation is complete, a configuration file SwaggerConfig. cs will appear in the App_Start folder.

Step 2:

Open the file and find c. IncludeXmlComments () in the Register () method. Add a parameter, that is, change it to c. IncludeXmlComments (GetXmlCommentsPath (thisAssembly. GetName (). Name ));

Then add a method at the same level as the Register method.

protected static string GetXmlCommentsPath(string name)        {            return string.Format(@"{0}\bin\{1}.XML", AppDomain.CurrentDomain.BaseDirectory, name);        }

Then the configuration file ends here,

Step 3:

Continue to configure the project

Right-click Project-> properties-> Generate-> select (XML document file)-> click Save file.

Step 4:

Enter the access path

http://localhost:15416/swagger/ui/index

Replace the host and port with the sent number.

Final results

Make a note here and find that there will be comments behind each request, and there will also be comments after opening. This is the comments in your interface, which can be directly taken for display.

/// <Summary> /// send the mobile phone Verification Code /// </summary> /// <param name = "mobile"> mobile phone number </param>

Reference: http://www.cnblogs.com/fangwei0505/p/6398382.html

At the same time put SpringMVC Demo: http://blog.csdn.net/u011499992/article/details/53455144

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.