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
- New WEBAPI Project
- Nuget introduces the appropriate class library Install-package Swashbuckle (Swaggerui 2.0)
- After introduction, the SwaggerConfig.cs file is generated in the App_start directory
- Modify the SwaggerConfig.cs file C.includexmlcomments function to introduce XML files that need to be included (C # summary annotations automatically generate XML files)
- Multiple projects need to introduce multiple XML files
- Modify the corresponding property of each item-"build-" output-"tick the XML document file
- 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