Currently in the use of ASP WebAPI2 to do background interface development, in the test with the front desk, always need to send a demo to him, but this is very troublesome, he may not remember.
Then you think of Swaggerui to generate the test document.
Don't say much, take a look at its specific usage!
The first step:
In VS2015 (the latter is your own tool) open the Package management console input:
Install-package Swashbuckle
Wait for the installation, after completion will find that in the App_start folder will be more than a configuration file SwaggerConfig.cs
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/756707/201702/756707-20170220165729007-172291445. PNG "style=" margin:0px;padding:0px;border:none; "/>
Step Two:
Open this file and find C in the register () method. Includexmlcomments (), add a parameter, i.e. change to C. Includexmlcomments (Getxmlcommentspath (Thisassembly.getname (). Name));
Then add a method to the same place 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 Three:
Continue to do the configuration for the project
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/756707/201702/756707-20170220170353757-1830263459. PNG "style=" margin:0px;padding:0px;border:none; "/>
Click Save file to create a tick (XML document file), properties-----project----right
Fourth Step:
Enter Access path
Http://localhost:15416/swagger/ui/index
Here the side about the host and port needs to be replaced by mail.
Final results
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/756707/201702/756707-20170220212111226-1110209949. PNG "style=" margin:0px;padding:0px;border:none; "/>
Here to make a note, found that each request will have comments behind, and after the opening of a note, this is your interface in the comments, it can be directly displayed.
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/756707/201702/756707-20170221092548898-1093429804. PNG "style=" margin:0px;padding:0px;border:none; "/>
<summary>///Send phone verification code///</summary>///<param name= "mobile" > Mobile phone number </param>
Swaggerui ASP. WebAPI2