本篇文章主要介绍了"Spring3 MVC中使用Swagger生成API文档",主要涉及到方面的内容,对于软件工程感兴趣的同学可以参考一下:
Spring3 MVC中使用Swagger生成API文档一:Swagger介绍Swagger是当前最好用的Restful API文档生成的开源项目,通过swag...
Spring3 MVC中使用Swagger生成API文档
一:Swagger介绍
Swagger是当前最好用的Restful API文档生成的开源项目,通过swagger-spring项目
实现了与SpingMVC框架的无缝集成功能,方便生成spring restful风格的接口文档,
同时swagger-ui还可以测试spring restful风格的接口功能。其官方网站为:
http://swagger.io/
二:Swagger集成Spring3 MVC步骤
Swagger集成springMVC步骤大致只有如下几步:
1.在pom.xml文件中添加swagger相关的依赖
com.mangofactory
swagger-springmvc
0.6.5
2.创建classpath路径下创建一个swagger.properties, 添加如下内容:
documentation.services.version=1.0
documentation.services.basePath=http://localhost:8080/yourcontextpath
3.在springMVC的main-servlet.xml文件添加如下配置
4.重新打包部署你的项目到WEB服务器,访问地址
http://localhost:8080/your-contextpath /api-docs即可看到注解生成的API说明
三:常见swagger注解一览与使用
APIs.@Api
@ApiClass
@ApiError
@ApiErrors
@ApiOperation
@ApiParam
@ApiParamImplicit