First, preface
In a recent mall project, use WEBAPI to build the API project. However, in the development process, the front-end engineers for the use of communication interfaces, is very time-consuming. I've also worked with swagger to build WEBAPI documents before, but the API documentation is not very readable. In particular, there are no instructions for passing in parameters and outgoing results, which can lead to difficult communication between developers. In the garden saw an article about the optimization of the swagger, there is a great improvement. Solve the incoming parameters, API sub-regional filtering issues, thank Bo Master Jiang Xuanbing.
However, after practice, there are still some unresolved problems:
- interface returned by the object, no Chinese description
- Interface Authorization parameter (token) not uniformly passed in
So, decide on this basis, and then do some optimization
Two, 1. Sub-regional display
2. Interface parameter description
3. Authorization Parameters Unified Incoming Token
4. Interface Query
5. Interface Development Status
Three, the key Realization 1. Project property settings generate an XML document file
2. Modify the SwaggerConfig.cs file
3. Modify the WebApiConfig.cs file to configure the routing
4. Sub-region selection of key logic
Note: implement logical and namespace separators. Have a lot to do, see file SwaggerAreasSupportDocumentFilter.cs
Four, the demo source address
github:github.com/yinboxie/swagger-demo.git
Download the demo source code, if found not automatically download NuGet dependency package, please execute command update-package-projectname ' Swagger.demo.api'-reinstall
After starting the project, access the address Http://localhost:11008/apis/index
V. Summary
swashbuckle Source code is no comment description, more difficult to read. I also just on the basis of the great God Jiang Xuanbing , modified several swashbuckle source code.
swashbuckle Source code after the change Github:github.com/yinboxie/swashbuckleex.git
Vi. references
- Webapi Document Description -swagger optimization