起因
有人问我,有没有Swagger的文章,我的程序启动不了。
当然有了,等我两小时,闲人老师写一篇。
说明
- Swagger:Swagger是一系列用于Restful API开发的工具
开源的部分包括
OpenAPI Specification
:API规范,规定了如何描述一个系统的API
Swagger Codegen
:用于通过API规范生成服务端和客户端代码
Swagger Editor
:用来编写API规范
Swagger UI
:用于展示API规范
非开源的部分包括
Swagger Hub
:云服务
Swagger Inspector
:手动测试API的工具
SoapUI Pro
:功能测试和安全测试的自动化工具
LoadUI Pro
:压力测试和性能测试的自动化工具
传送门:https://swagger.io - Springfox:通过扫描代码提取代码中的信息,生成API文档的工具
springfox-swagger
是Springfox
旗下的一个项目
springfox-swagger
支持按OpenAPI Specification
规范生成文档
除此之外springfox
还可以按RAML
、jsonapi
生成
传送门:http://springfox.github.io/springfox
使用springfox-swagger
配置方法
<dependencies>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-data-rest</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
默认文档地址
http://localhost:8080/springfox
传送门:http://springfox.github.io/springfox/docs/current/#springfox-swagger-ui
总结
闲人老师使用springfox已经是去年的事情了,如有变化,欢迎留下评论。