swag
swag copied to clipboard
Result is nil, @Success 200 {object} gin.H {"msg": "","data": "","code": 200}
trafficstars
I write such an interface and return gin.H{} Screenshot below:

but this struct is nil . I made a mistake myself, I hope to get your answer

Excuse me, how did you solve it ?
@success 200 {object} jsonresult.JSONResult{data=nil} "desc"
data should be nil, nil will be json null
but this feature does not work
OAS defines the data types, not values.
type JSONResult struct {
Code int `json:"code" `
Message string `json:"message"`
Data interface{} `json:"data"`
}
The annotation @success 200 {object} jsonresult.JSONResult{data=proto.Order} "desc" will define the type for JSONResult.Data as been a proto.Order. The OAS model definition will look like this:
type JSONResult struct {
Code int `json:"code" `
Message string `json:"message"`
Data proto.Order `json:"data"`
}