增加swagger文档接口定义
This commit is contained in:
commit
a8c9243024
23
.gitignore
vendored
Normal file
23
.gitignore
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
# Created by .ignore support plugin (hsz.mobi)
|
||||
### Go template
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
||||
.idea
|
||||
.vscode
|
||||
.fleet
|
||||
release
|
||||
logs
|
||||
.scannerwork
|
23
define/consts.go
Normal file
23
define/consts.go
Normal file
@ -0,0 +1,23 @@
|
||||
// Package define ...
|
||||
//
|
||||
// Description : define ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 2024-04-19 12:12
|
||||
package define
|
||||
|
||||
const (
|
||||
SwaggerVersion2 = "2.0"
|
||||
)
|
||||
|
||||
const (
|
||||
LicenseApache2 = "Apache 2.0" // apache
|
||||
)
|
||||
|
||||
var (
|
||||
// LicenseLinkTable 开源协议内容映射表
|
||||
LicenseLinkTable = map[string]string{
|
||||
LicenseApache2: "http://www.apache.org/licenses/LICENSE-2.0.html",
|
||||
}
|
||||
)
|
115
define/types.go
Normal file
115
define/types.go
Normal file
@ -0,0 +1,115 @@
|
||||
// Package define ...
|
||||
//
|
||||
// Description : define ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 2024-04-19 12:07
|
||||
package define
|
||||
|
||||
// Contact 联系人信息
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:08 2024/4/19
|
||||
type Contact struct {
|
||||
Name string `json:"name"` // 姓名
|
||||
Url string `json:"url"` // 主页地址
|
||||
Email string `json:"email"` // 邮箱
|
||||
}
|
||||
|
||||
// License 开源协议
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:09 2024/4/19
|
||||
type License struct {
|
||||
Name string `json:"name"` // 开源协议名
|
||||
Url string `json:"url"` // 开源协议地址
|
||||
}
|
||||
|
||||
// Info 信息
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:10 2024/4/19
|
||||
type Info struct {
|
||||
Description string `json:"description"` // 文档描述
|
||||
Title string `json:"title"` // 文档标题
|
||||
Contact Contact `json:"contact"` // 联系方式
|
||||
License License `json:"license"` // 开源协议
|
||||
Version string `json:"version"` // 文档版本
|
||||
}
|
||||
|
||||
// SwaggerPathConfig ...
|
||||
//
|
||||
// Author : zhangdeman001@ke.com<张德满>
|
||||
//
|
||||
// Date : 16:16 2024/4/19
|
||||
type SwaggerPathConfig struct {
|
||||
Description string `json:"description"` // 接口描述
|
||||
Consumes []string `json:"consumes"` // 请求方式, application/json等
|
||||
Tags []string `json:"tags"` // 接口标签
|
||||
Summary string `json:"summary"` // 接口摘要
|
||||
Parameters []SwaggerPathConfigParameter `json:"parameters"` // 参数列表
|
||||
Response map[string]SwaggerPathConfigResponse `json:"response"` // code码 => 响应描述
|
||||
}
|
||||
|
||||
// SwaggerPathConfigParameter ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:53 2024/4/19
|
||||
type SwaggerPathConfigParameter struct {
|
||||
Type string `json:"type"` // 类型
|
||||
Description string `json:"description"` // 描述
|
||||
Name string `json:"name"` // 参数名称
|
||||
In string `json:"in"` // 参数位置
|
||||
Required bool `json:"required"` // 是都必传
|
||||
Schema map[string]string `json:"schema"` // 参数schema
|
||||
}
|
||||
|
||||
// SwaggerPathConfigResponse ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:57 2024/4/19
|
||||
type SwaggerPathConfigResponse struct {
|
||||
Description string `json:"description"` // 返回值描述
|
||||
Schema map[string]string `json:"schema"` // 返回值结构
|
||||
}
|
||||
|
||||
// SwaggerDefinition ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 17:01 2024/4/19
|
||||
type SwaggerDefinition struct {
|
||||
Type string `json:"type"` // 类型
|
||||
Required []string `json:"required"` // 必传参数列表
|
||||
Properties map[string]SwaggerDefinitionProperty `json:"properties"` // 参数名 => 参数配置
|
||||
}
|
||||
|
||||
// SwaggerDefinitionProperty ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 17:25 2024/4/19
|
||||
type SwaggerDefinitionProperty struct {
|
||||
Description string `json:"description"` // 描述
|
||||
Type string `json:"type"` // 类型
|
||||
}
|
||||
|
||||
// Swagger 文档整体结构定义
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:12 2024/4/19
|
||||
type Swagger struct {
|
||||
Schemes []string `json:"schemes"`
|
||||
Swagger string `json:"swagger"` // swagger版本 - 2.0
|
||||
Host string `json:"host"` // 服务域名
|
||||
BasePath string `json:"basePath"` // 基础path
|
||||
Paths map[string]map[string]SwaggerPathConfig `json:"paths"` // 接口列表 : 接口 => 请求方法 => 请求配置
|
||||
Definitions map[string]SwaggerDefinition `json:"definitions"` // 数据定义
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user