go gin swagger 修改 结构体 swagger 类型

122 阅读1分钟

使用<font style="color:rgb(31, 35, 40);">swaggertype</font>标签更改字段类型

type RecordCategory struct {
	common.OrmModel
	Name    string         `json:"name"` // 分类名称
	UserID  uint           `json:"userId"`
	User    user.User      `json:"user"`
	Default bool           `json:"default"`                    // 是否是默认分类
	Image   datatypes.JSON `json:"image" swaggertype:"object"` // 分类图片
}

相关链接:swaggo github链接