gf
gf copied to clipboard
swagger缺少每一个path的Security配置
1. What version of Go
and system type/arch are you using?
GoFrame CLI Tool v2.0.0-rc, https://goframe.org
GoFrame Version: v2.0.0-rc2 in current go.mod
CLI Installed At: E:\go-workspace\bin\gf.exe
CLI Built Detail:
Go Version: go1.17.6
GF Version: v2.0.0-beta
Git Commit: 2022-01-24 11:02:57 37d535f61e975dff1765f98e3b505aeccfec338e
Build Time: 2022-01-24 03:01:42
2. What did you do?
在openapi文档上增加了统一token校验
openapi.Components = goai.Components{
SecuritySchemes: goai.SecuritySchemes{
"APIKeyAuth": goai.SecuritySchemeRef{
Ref: "", // 暂时还不知道该值是干什么用的
Value: &goai.SecurityScheme{
Type: "apiKey",
In: "header",
Name: "Authorization",
BearerFormat: "Bearer",
},
},
},
}
但是使用 try it out功能时,并没有在token上增加Authorization。
3. What did you expect to see?
期望实现了该效果:swagger_ui.png (1217×599) (smartbear.co) 类似于这个图上的 那个 Authorize按钮和每个API后边的那个锁图标,实际体验可以看 Swagger UI 这个demo的apiKey方式。
4. What did you see instead?
swaagerUI页面上没有实现在token上增加Authorization
5. 建议实现方案
- 可以在xxxReq的meta上增加每一个path对应的Security配置
- 可以在server启动之后,还可以修改openAPI对象
openAPI的规范文档参考:https://openapi.apifox.cn/#security-requirement-%E5%AF%B9%E8%B1%A1
@XiaobinZhao 这个功能你可以贡献下PR,或者等社区贡献PR。
https://github.com/gogf/gf/pull/1820 已提交PR
这个功能实现了么?好像没相关的文档呀, @gqcn
@itltf512116 merge 没有合入。郭强大大说是缺少测试代码,我还没搞。
这个功能还没加上么
@1211ciel 啊,一直没空看,最近看看
@gqcn Openapi path security #2377 merge 重新提了,可以审核下
@1211ciel merge 已合入了,你可以看看