Open 371873574 opened 1 year ago
// JSONResult's data field will be overridden by the specific type proto.Order @success 200 {object} jsonresult.JSONResult{data=proto.Order} "desc"
in your case:
@Success 200 {object} Response{data=[]httpresponses.ResponseItem}
// JSONResult's data field will be overridden by the specific type proto.Order @success 200 {object} jsonresult.JSONResult{data=proto.Order} "desc"
in your case:
@success 200 {object} Response{data=[]httpresponses.ResponseItem}
Actually, it hasn't completely solved my problem. Where is the specific document address? I'll study it
Reference right here: https://github.com/swaggo/swag/blob/master/README.md#model-composition-in-response
Reference right here: https://github.com/swaggo/swag/blob/master/README.md#model-composition-in-response
thanks!
Reference right here: https://github.com/swaggo/swag/blob/master/README.md#model-composition-in-response
type Vo struct {
Id string json:"id,omitempty"
Name string json:"name,omitempty"
Permission []permission.Resp json:"permission,omitempty"
IsPreset uint json:"isPreset"
CreateTime string json:"createTime,omitempty"
UpdateTime string json:"updateTime,omitempty"
}
Add does not require an ID, update requires an ID. How to use the same vo struct
Brother, have you solved this problem? I have exactly the same problem as you.
My response structure is like this data is an interface type
type Response struct {
Code int `json:"code"`
Data interface{} `json:"data"`
Message string `json:"message"`
}
It's ok for me to write like this when responding @Success 200 {object} response.Response{} "响应示例"
But the example value displayed above the page is like this.
{
"code": 0,
"data": "string",
"message": "string"
}
The result I want is to add an example value to data, something like this
{
"code": 0,
"data": {
"token": "50e1689dbccc9b48e3c8797aabe542",
"money": "5.800"
},
"message": "success"
}
I tried to use the example below to supplement the sample value of data, but when swag init it prompts :invalid type: response.Response{data=map[string]interface{}{
@Success 200 {object} response.Response{data=map[string]interface{}{"token": "1234","money":"123"}} "响应示例"
type Response struct { Code int
json:"code"
Msg stringjson:"msg"
Data interface{}json:"data"
} How to declare specific structures for data,becase of defining data as an interface can improve scalability { "code": 200, "msg": "success", "data": { "total": 100, "list": [{ "name":"test", "namespace": "default" }] } }