upgrade: 优化部分代码, 部分内容待配置化

This commit is contained in:
2025-08-23 01:09:57 +08:00
parent 14e56e4caf
commit bac8242f5e
19 changed files with 169 additions and 153 deletions

View File

@ -10,12 +10,14 @@ package api_doc
import (
"errors"
"fmt"
"git.zhangdeman.cn/gateway/api-doc/define"
"git.zhangdeman.cn/zhangdeman/consts"
"git.zhangdeman.cn/zhangdeman/wrapper"
"net/http"
"reflect"
"strings"
"git.zhangdeman.cn/gateway/api-doc/define"
"git.zhangdeman.cn/gateway/api-doc/enums"
"git.zhangdeman.cn/zhangdeman/consts"
"git.zhangdeman.cn/zhangdeman/wrapper"
)
// NewOpenapiDoc ...
@ -260,10 +262,6 @@ func (g *Generate) setApiDoc(baseCfg *define.UriBaseConfig, apiDocCfg *define.Pa
}
// getApiDocBaseCfg 获取接口文档的基础配置
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 16:10 2025/2/14
func (g *Generate) getApiDocBaseCfg(baseCfg *define.UriBaseConfig, paramType reflect.Type) *define.PathItemOperationConfig {
cfg := &define.PathItemOperationConfig{
Tags: baseCfg.TagList,
@ -279,7 +277,7 @@ func (g *Generate) getApiDocBaseCfg(baseCfg *define.UriBaseConfig, paramType ref
Ref: "",
},
Responses: map[string]*define.Response{
fmt.Sprintf("%v", http.StatusOK): &define.Response{
fmt.Sprintf("%v", http.StatusOK): {
Content: map[string]*define.Media{},
},
},
@ -295,12 +293,12 @@ func (g *Generate) getApiDocBaseCfg(baseCfg *define.UriBaseConfig, paramType ref
param = strings.TrimSuffix(param, "}")
cfg.Parameters = append(cfg.Parameters, &define.PathConfigParameter{
Name: param,
In: consts.SwaggerParameterInPath,
In: enums.DocParamLocationPath.String(),
Description: param,
Required: true,
Deprecated: false,
Schema: &define.Schema{
Type: consts.SwaggerDataTypeString,
Type: enums.SwaggerDataTypeString.String(),
Format: consts.DataTypeString.String(),
},
AllowEmptyValue: false,
@ -311,10 +309,6 @@ func (g *Generate) getApiDocBaseCfg(baseCfg *define.UriBaseConfig, paramType ref
}
// ParseReadConfigParam 解析get类请求参数
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 11:55 2025/2/14
func (g *Generate) ParseReadConfigParam(requestCfg *define.UriBaseConfig, baseReqCfg *define.PathItemOperationConfig, inputType reflect.Type) {
if inputType.Kind() == reflect.Ptr {
inputType = inputType.Elem()