Go 常用工具之swagger
前言
一、结构体注释规范
type detailResponse struct {
Name string json:"name"
// 任务名称
Spec string json:"spec"
// crontab 表达式
Command string json:"command"
// 执行命令
Protocol int32 json:"protocol"
// 执行方式 1:shell 2:http
HttpMethod int32 json:"http_method"
// http 请求方式 1:get 2:post
Timeout int32 json:"timeout"
// 超时时间(单位:秒)
RetryTimes int32 json:"retry_times"
// 重试次数
RetryInterval int32 json:"retry_interval"
// 重试间隔(单位:秒)
NotifyStatus int32 json:"notify_status"
// 执行结束是否通知 1:不通知 2:失败通知 3:结束通知 4:结果关键字匹配通知
NotifyType int32 json:"notify_type"
// 通知类型 1:邮件 2:webhook
NotifyReceiverEmail string json:"notify_receiver_email"
// 通知者邮箱地址(多个用,分割)
NotifyKeyword string json:"notify_keyword"
// 通知匹配关键字(多个用,分割)
Remark string json:"remark"
// 备注
IsUsed int32 json:"is_used"
// 是否启用 1:是 -1:否
}
二、接口和函数实现规范
type Handler interface {
// HashIdsEncode HashIds 加密
// @Tags API.tool
// @Router /api/tool/hashids/encode/{id} [get]
HashIdsEncode() core.HandlerFunc
}
如果我的内容能帮上你是我的荣幸,如果能打赏一下那就是对我最大的鼓励