Use the swagger

Source: Internet
Author: User

Reference: https://www.cnblogs.com/xcsn/p/7910890.html

Step 1: nuget install swashbuckle to *. webapi Project

Step 2: In *. webapi "app_start" swaggerconfig. CS, delete unnecessary comments and only use them.

Using system. web. HTTP; using webactivatorex; using framework; using swashbuckle. application; using system. io; using system. LINQ; [Assembly: preapplicationstartmethod (typeof (swaggerconfig), "register")] namespace framework {public class swaggerconfig {public static void register () {var thisassembly = typeof (swaggerconfig ). assembly; globalconfiguration. configuration. enableswagger (C => {C. singleapiversion ("V1", "Framework"); // This framework is automatically generated based on the prefix of the project. You can just change it to your own. C. includexmlcomments (getxmlcommentspath ("application"); C. usefulltypenameinschemaids (); C. resolveconflictingactions (apidescriptions => apidescriptions. first ());}). enableswaggerui ("APIs/{* assetpath}");} Private Static string getxmlcommentspath (string subname) {return directory. getfiles (system. appdomain. currentdomain. basedirectory + "bin \\"). firstordefault (n => N. tolower (). endswith (subname. tolower () + ". XML "));}}}

Step 3 :*. select application project right-click Properties generate output, select [XML document file], and modify the path: bin \ framework. application. XML is to remove the debugging in the middle.

Step 4: Compile the solution, set the WEB Project startup Item, CTRL + F5, address bar: http: // localhost: 61814/APIs/index, and you will see the result.

Use the swagger

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.