swagger文档生成 : 增加输入配置的格式化

This commit is contained in:
2024-04-22 11:54:03 +08:00
parent 091d0b7a0f
commit 114b5db641
5 changed files with 215 additions and 9 deletions

View File

@ -47,12 +47,12 @@ type Info struct {
//
// 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码 => 响应描述
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 ...
@ -65,7 +65,7 @@ type SwaggerPathConfigParameter struct {
Description string `json:"description"` // 描述
Name string `json:"name"` // 参数名称
In string `json:"in"` // 参数位置
Required bool `json:"required"` // 是必传
Required bool `json:"required"` // 是必传
Schema map[string]string `json:"schema"` // 参数schema
}
@ -110,6 +110,62 @@ type Swagger struct {
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"` // 数据定义
}
// SwaggerInput ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 10:18 2024/4/22
type SwaggerInput 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"` // 文档描述信息
PathConfigList []*SwaggerPathInput `json:"path_config_list"` // 接口配置列表
}
// SwaggerPathInput 接口配置
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 10:20 2024/4/22
type SwaggerPathInput struct {
Uri string `json:"uri"` // 接口
Method string `json:"method"` // 请求方法
ContentType string `json:"content_type"` // 请求方式
Summary string `json:"summary"` // 摘要
Description string `json:"description"` // 描述
TagList []string `json:"tag_list"` // 标签列表
ParameterList []*SwaggerParameterInput `json:"parameter_list"` // 参数列表
ResponseList []*SwaggerResponseInput `json:"response_list"` // 响应数据
}
// SwaggerParameterInput ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 10:25 2024/4/22
type SwaggerParameterInput struct {
Type string `json:"type"` // 类型
Description string `json:"description"` // 描述
Name string `json:"name"` // 参数名称
In string `json:"in"` // 参数位置
Required bool `json:"required"` // 是否必传
}
// SwaggerResponseInput 响应数据
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 10:49 2024/4/22
type SwaggerResponseInput struct {
Type string `json:"type"` // 类型
Description string `json:"description"` // 描述
Field string `json:"field"` // 字段名
IsRequired bool `json:"is_required"` // 是否一定存在
}