ASP. WEBAPI Generate Swaggerui Document

Source: Internet
Author: User

Why we need documentation

Good documentation makes it easier to develop and communicate back and forth.

Advantages of Swagger UI documentation

Can be tested on-line for convenient front-end commissioning

Use steps

    1. New WEBAPI Project
    2. Nuget introduces the appropriate class library Install-package Swashbuckle (Swaggerui 2.0)
    3. After introduction, the SwaggerConfig.cs file is generated in the App_start directory
    4. Modify the SwaggerConfig.cs file C.includexmlcomments function to introduce XML files that need to be included (C # summary annotations automatically generate XML files)
    5. Multiple projects need to introduce multiple XML files
    6. Modify the corresponding property of each item-"build-" output-"tick the XML document file
    7. Start Project Access Xxx:xx/swagger can see the automatic generation of documents, corresponding to JSON, you can view the Swaggerui header input box connection

Common errors

1 Direct access does not load the document, if you use json.net serialization, you need to set nullhanding to ignore

Settings. nullvaluehandling = Nullvaluehandling.ignore;

  

2 If the generated complex parameters do not resolve correctly to the object, check whether the Json.NET hump is set to return

ASP. WEBAPI Generate Swaggerui Document

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.