怎么想springboot项目中使用swagger-spring-boot-starter - Go语言中文社区

怎么想springboot项目中使用swagger-spring-boot-starter


一直使用swagger,最近发现一款在swagger基础开发的api文档接口生成框架swagger-spring-boot-starter。我们先看看他生成的效果吧。


7798479-e29e0815443da1b0.png

1.加入依赖

7798479-98940fb7f61fe3ce.png

2.添加配置

spring.swagger.enabled=true

spring.swagger.security.filter-plugin=true

# 配置

spring.swagger.api-key.key-name=myToken

# 2.0.1 版本新特性 (支持可选的 Bean 验证插件)

# 配置账号密码

spring.swagger.security.username=battcn

spring.swagger.security.password=battcn

spring.swagger.base-package=com.cornerstone.verification.controller

# 关闭 JSR

spring.swagger.validator-plugin=false

3.启动项目输入:http://localhost:8083/swagger-ui.html 会有一个登陆接口 用户密码在配置文件里配置了。

4.一些swagger有用的注释:

(1)在接口上加上这个

@ApiImplicitParams({

@ApiImplicitParam(name="domainId",value="系统number",dataType="String",required=true),

        @ApiImplicitParam(name="username",value="用户名",dataType="String",required=true),

        @ApiImplicitParam(name="password",value="密码",dataType="String",required=true),

        @ApiImplicitParam(name="redirect",value="重定向地址",dataType="String",required=false)

})

注释参数信息。

版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/dengwt123/article/details/84868058
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2020-03-01 17:50:27
  • 阅读 ( 1071 )
  • 分类:

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢