swagger2详解
[toc]
为啥使用swagger2
- 由于接口众多,调用者不懂如何使用接口参数,并且接口逻辑复杂(需要考虑不同的HTTP请求类型、HTTP头部信息、HTTP请求内容等)
- 随着时间推移,不断修改接口实现的时候都必须同步修改接口文档,否则很容易导致不一致现象
- 能不能自动生成API文档的框架?
swagger2的作用
自动生成文档和测试接口的ui
swagger2的使用
pom文件添加依赖
<!-- Begin: API自动生成文档(swagger2) -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
<!-- End: API自动生成文档(swagger2) -->
网友评论