New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@Success 200 {array} json "{"code":200,"data":model.Account,"msg":"success"}" #390
Comments
? |
Think what they are trying to ask for is a way to define a struct for a response directly in the comment rather than having to build out a struct and link it. It would be a nice feature in my opinion as some times I have single variable responses from my api's and having to make a struct with one variable inside of it in order to link it for the docs can get kind of tedious at times. |
@ddaggHT if you are going to work with json , just declare a standard Response format like the following and you can use it as response in all controllers.
or
|
Actualy is not a simple response , since "data" is a type of model.Account . |
type Response struct { // @success 200 {object} utils.Response{data:model.User} "{"code":0,"data":model.User,"msg":"ok"}" this's good ,but it don't worker |
Has the above problem been solved? |
I have the same problem |
example (Java generics)
type JsonResult struct{
code int
msg string
data interface{}
}
type Account struct{
}
xxxx
xxx
@success 200 {array} json "{"code":200,"data":model.Account,"msg":"success"}"
func Get() {
a:=Account{}
json:=JsonResult{code:1,msg:"",data=&a}
x.JSON(json)
}
swag init
The text was updated successfully, but these errors were encountered: