Open qinains opened 1 week ago
这个问题,我目前的解决方式是在嵌入结构体中加指针引用,你可以试试
type LogoutReq struct {
g.Meta `method:"post" path:"/logout" summary:"用户退出登录" tags:"auth"`
*TokenReq
}
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
My current solution to this problem is to add pointer references to the embedded structure. You can try it.
typeLogoutReq struct {
g.Meta `method:"post" path:"/logout" summary:"User logs out" tags:"auth"`
*TokenReq
}
这个问题,我目前的解决方式是在嵌入结构体中加指针引用,你可以试试
type LogoutReq struct { g.Meta `method:"post" path:"/logout" summary:"用户退出登录" tags:"auth"` *TokenReq }
但是依然有以下问题:body必填。(期待的结果是body不必填)
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
My current solution to this problem is to add pointer references to the embedded structure. You can try it.
type LogoutReq struct { g.Meta `method:"post" path:"/logout" summary:"User logs out" tags:"auth"` *TokenReq }
But there are still the following problems: body is required. (The expected result is that the body does not need to be filled in)
Go version
go version go1.22.0 windows/amd64
GoFrame version
2.7.1
Can this bug be reproduced with the latest release?
Option Yes
What did you do?
// 启动Http Server s.Run()
What did you see happen?
生成的api.json文件为:
What did you expect to see?
如果xxxReq没有必须的参数,生成的api.json的requestBody的required是否应该为false?如下
P.S. 如果设置添加“mime:"application/x-www-form-urlencoded"”,就显示正常。(但是上面的例子,我又想让mime为application/json,可能以后添加其他参数) type LogoutReq struct { g.Meta
mime:"application/x-www-form-urlencoded" method:"post" path:"/logout" summary:"用户退出登录" tags:"auth"
TokenReq }