57 lines
4.6 KiB
Go
57 lines
4.6 KiB
Go
// Package parser ...
|
|
//
|
|
// Description : parser ...
|
|
//
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
//
|
|
// Date : 2025-04-11 20:21
|
|
package define
|
|
|
|
// ApiConfig 解析出的接口配置
|
|
//
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
//
|
|
// Date : 20:21 2025/4/11
|
|
type ApiConfig struct {
|
|
Tag string `json:"tag" dc:"接口所属标签"` // 接口所属标签
|
|
Name string `json:"name" binding:"required,min=1" dc:"接口名称" err:"项目接口名称必须存在,且不能为空"` // 接口名称
|
|
Uri string `json:"uri" binding:"required,min=1,max=512" dc:"项目接口uri" err:"项目接口路径必须存在,且长度在[1,512]之间"` // 项目接口路由
|
|
MethodID int64 `json:"method_id" dc:"请求方法ID"` // 请求方法
|
|
Method string `json:"method" binding:"required_without=MethodID" dc:"请求方法" err:"请求方法与请求方法ID至少存在一个"`
|
|
ContentType string `json:"content_type" dc:"请求类型" binding:"required_without=ContentTypeID" err:"请求类型ID与请求类型至少存在一个"`
|
|
Description string `json:"description" dc:"项目接口描述"` // 接口描述
|
|
ParamList []*ApiParamItem `json:"param_list" dc:"项目接口参数列表"` // 参数列表
|
|
ResultList []*ApiResultItem `json:"result_list" dc:"项目接口返回值列表"` // 返回值列表
|
|
}
|
|
|
|
// ApiParamItem 接口参数配置
|
|
//
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
//
|
|
// Date : 20:23 2025/4/11
|
|
type ApiParamItem struct {
|
|
Title string `json:"title" binding:"required,min=1" dc:"参数标题" err:"参数标题必须存在,且不能为空"` // 参数标题
|
|
Name string `json:"name" binding:"required,min=1" dc:"参数名称" err:"参数名称必须存在,且不能为空"` // 参数名称
|
|
Location string `json:"location" binding:"required,oneof=HEADER COOKIE BODY QUERY PATH" dc:"参数位置" err:"参数位置必须存在,且需要是一个有效合法值"` // 参数位置
|
|
ParamType string `json:"param_type" binding:"required,validate_data_type" dc:"参数类型" err:"参数类型必须存在,且需要是一个有效的合法值"` // 参数类型
|
|
IsRequired bool `json:"is_required" binding:"required" dc:"参数是否必传" err:"参数是否必传必须存在,且需要是一个有效合法值"` // 是否必传
|
|
DefaultValue string `json:"default_value" dc:"默认值"` // 默认值
|
|
ExampleValue string `json:"example_value" dc:"示例值"` // 示例值
|
|
Description string `json:"description" dc:"参数描述"` // 参数描述
|
|
}
|
|
|
|
// ApiResultItem 接口返回值配置
|
|
//
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
//
|
|
// Date : 20:23 2025/4/11
|
|
type ApiResultItem struct {
|
|
Title string `json:"title" binding:"required,min=1,max=64" dc:"返回值标题" err:"返回值标题必须存在,且长度在[1,64]之间"` // 返回值标题
|
|
DataPath string `json:"data_path" binding:"required,min=1,max=512" dc:"返回值路径" err:"返回值路径必须存在,且长度在[1,512]之间"` // 返回值路径
|
|
DataLocation string `json:"data_location" binding:"required,oneof=BODY HEADER COOKIE" dc:"返回值位置" err:"返回值位置必须存在,其需要时一个有效的合法值"` // 返回值位置
|
|
DataType string `json:"data_type" binding:"required,validate_data_type" dc:"返回值类型" err:"返回值类型必须存在,且需要是一个有效的合法值"` // 返回值类型
|
|
DefaultValue string `json:"default_value" dc:"默认值"` // 默认值
|
|
ExampleValue string `json:"example_value" dc:"示例值"` // 示例值
|
|
Description string `json:"description" dc:"返回值描述"` // 返回值描述
|
|
}
|