优化swagger文档生成

This commit is contained in:
2025-02-07 21:27:33 +08:00
parent 28419222a7
commit 1d7b81cffa
6 changed files with 72 additions and 64 deletions

View File

@ -80,12 +80,12 @@ type SwaggerDefinition struct {
//
// Date : 17:25 2024/4/19
type SwaggerDefinitionProperty struct {
Description string `json:"description"` // 描述
Type string `json:"type"` // 类型
Items *SwaggerDefinitionPropertyItem `json:"items,omitempty"` // 引用类型中的引用(数组)
AllOf []map[string]string `json:"allOf,omitempty"` // 引用类型中的引用(对象)
XGoName string `json:"x-go-name"` // go字段名称
XGoPackage string `json:"x-go-package"` // go 包路径
Description string `json:"description"` // 描述
Type string `json:"type"` // 类型
Items *SwaggerDefinitionPropertyItem `json:"items,omitempty"` // 引用类型中的引用(数组)
AllOf []map[string]string `json:"allOf,omitempty"` // 引用类型中的引用(对象)
XGoName string `json:"x-go-name,omitempty"` // go字段名称
XGoPackage string `json:"x-go-package,omitempty"` // go 包路径
}
// SwaggerDefinitionPropertyItem 属性item兴义
@ -102,14 +102,14 @@ type SwaggerDefinitionPropertyItem struct {
// 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
Info Info `json:"info"` // 文档描述信息
Paths map[string]map[string]*SwaggerPathConfig `json:"paths"` // 接口列表 : 接口 => 请求方法 => 请求配置
Definitions map[string]*SwaggerDefinition `json:"definitions"` // 数据定义
Responses map[string]*SwaggerPathConfigResponse `json:"responses"` // 响应结构列表
SecurityDefinitions map[string]*SwaggerPathConfigParameter `json:"securityDefinitions"` // 安全选项
Swagger string `json:"swagger"` // swagger版本 - 2.0
Host string `json:"host"` // 服务域名
BasePath string `json:"basePath"` // 基础path
Info Info `json:"info"` // 文档描述信息
Paths map[string]map[string]*SwaggerPathConfig `json:"paths"` // 接口列表 : 接口 => 请求方法 => 请求配置
Definitions map[string]*SwaggerDefinition `json:"definitions,omitempty"` // 数据定义
Responses map[string]*SwaggerPathConfigResponse `json:"responses,omitempty"` // 响应结构列表
SecurityDefinitions map[string]*SwaggerPathConfigParameter `json:"securityDefinitions,omitempty"` // 安全选项
}
// SwaggerInput ...