feat: code cleanup
This commit is contained in:
@@ -88,10 +88,6 @@ func (hod *handleOpenapiDoc) Parse() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// apiPathConfigToProjectConfig 解析请求方法
|
// apiPathConfigToProjectConfig 解析请求方法
|
||||||
//
|
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
|
||||||
//
|
|
||||||
// Date : 18:48 2025/2/26
|
|
||||||
func (hod *handleOpenapiDoc) apiPathConfigToProjectConfig(uri string, method string, apiPathConfig *apiDocDefine.PathItemOperationConfig) error {
|
func (hod *handleOpenapiDoc) apiPathConfigToProjectConfig(uri string, method string, apiPathConfig *apiDocDefine.PathItemOperationConfig) error {
|
||||||
if hod.ignoreApiTable[fmt.Sprintf("%v_%v", strings.ToUpper(method), uri)] {
|
if hod.ignoreApiTable[fmt.Sprintf("%v_%v", strings.ToUpper(method), uri)] {
|
||||||
// 接口已存在
|
// 接口已存在
|
||||||
@@ -152,10 +148,6 @@ func (hod *handleOpenapiDoc) apiPathConfigToProjectConfig(uri string, method str
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handleRequestBody 解析request body
|
// handleRequestBody 解析request body
|
||||||
//
|
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
|
||||||
//
|
|
||||||
// Date : 12:17 2025/2/27
|
|
||||||
func (hod *handleOpenapiDoc) handleRequestBody(importUriConfig *apiDocDefine.ApiConfig, requestBodyData *apiDocDefine.RequestBody, selectRequestContentType string) error {
|
func (hod *handleOpenapiDoc) handleRequestBody(importUriConfig *apiDocDefine.ApiConfig, requestBodyData *apiDocDefine.RequestBody, selectRequestContentType string) error {
|
||||||
if nil == requestBodyData || nil == requestBodyData.Content {
|
if nil == requestBodyData || nil == requestBodyData.Content {
|
||||||
return nil
|
return nil
|
||||||
@@ -363,10 +355,6 @@ func (hod *handleOpenapiDoc) expendObjectOrArrayRequest(importUriConfig *apiDocD
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handleResponseBody 解析响应body
|
// handleResponseBody 解析响应body
|
||||||
//
|
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
|
||||||
//
|
|
||||||
// Date : 13:44 2025/2/27
|
|
||||||
func (hod *handleOpenapiDoc) handleResponseBody(importUriConfig *apiDocDefine.ApiConfig, requestBodyTable map[string]*apiDocDefine.Response) error {
|
func (hod *handleOpenapiDoc) handleResponseBody(importUriConfig *apiDocDefine.ApiConfig, requestBodyTable map[string]*apiDocDefine.Response) error {
|
||||||
if nil == requestBodyTable || nil == requestBodyTable["200"] {
|
if nil == requestBodyTable || nil == requestBodyTable["200"] {
|
||||||
return nil
|
return nil
|
||||||
@@ -424,10 +412,6 @@ func (hod *handleOpenapiDoc) handleResponseBody(importUriConfig *apiDocDefine.Ap
|
|||||||
}
|
}
|
||||||
|
|
||||||
// expendObjectOrArrayPath 展开ref对象路径
|
// expendObjectOrArrayPath 展开ref对象路径
|
||||||
//
|
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
|
||||||
//
|
|
||||||
// Date : 15:28 2025/4/8
|
|
||||||
func (hod *handleOpenapiDoc) expendObjectOrArrayPath(importUriConfig *apiDocDefine.ApiConfig, rootRef string, parentPath string, currentPropertyName string, currentProperty *apiDocDefine.Property) error {
|
func (hod *handleOpenapiDoc) expendObjectOrArrayPath(importUriConfig *apiDocDefine.ApiConfig, rootRef string, parentPath string, currentPropertyName string, currentProperty *apiDocDefine.Property) error {
|
||||||
if len(parentPath) > 0 {
|
if len(parentPath) > 0 {
|
||||||
currentPropertyName = parentPath + "." + currentPropertyName
|
currentPropertyName = parentPath + "." + currentPropertyName
|
||||||
@@ -581,10 +565,6 @@ func (hod *handleOpenapiDoc) expendObjectOrArrayPath(importUriConfig *apiDocDefi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// getResComponentsConfig 获取ref指向components的定义
|
// getResComponentsConfig 获取ref指向components的定义
|
||||||
//
|
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
|
||||||
//
|
|
||||||
// Date : 11:17 2025/2/27
|
|
||||||
func (hod *handleOpenapiDoc) getResComponentsConfig(ref string) (*apiDocDefine.Schema, error) {
|
func (hod *handleOpenapiDoc) getResComponentsConfig(ref string) (*apiDocDefine.Schema, error) {
|
||||||
refKey := strings.TrimPrefix(ref, "#/components/schemas/")
|
refKey := strings.TrimPrefix(ref, "#/components/schemas/")
|
||||||
if _, exist := hod.docRes.Components.Schemas[refKey]; exist {
|
if _, exist := hod.docRes.Components.Schemas[refKey]; exist {
|
||||||
@@ -599,10 +579,6 @@ func (hod *handleOpenapiDoc) getResComponentsConfig(ref string) (*apiDocDefine.S
|
|||||||
}
|
}
|
||||||
|
|
||||||
// openapiDocLocationFormat 文档数据位置转为网关的数据位置
|
// openapiDocLocationFormat 文档数据位置转为网关的数据位置
|
||||||
//
|
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
|
||||||
//
|
|
||||||
// Date : 21:06 2025/2/26
|
|
||||||
func (hod *handleOpenapiDoc) openapiDocLocationFormat(openapiDocLocation string) string {
|
func (hod *handleOpenapiDoc) openapiDocLocationFormat(openapiDocLocation string) string {
|
||||||
openapiDocLocation = strings.ToUpper(openapiDocLocation)
|
openapiDocLocation = strings.ToUpper(openapiDocLocation)
|
||||||
for _, itemLocation := range consts.RequestDataLocationList {
|
for _, itemLocation := range consts.RequestDataLocationList {
|
||||||
@@ -615,10 +591,6 @@ func (hod *handleOpenapiDoc) openapiDocLocationFormat(openapiDocLocation string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// openapiDocType2GoType 文档数据类型转为网关数据类型
|
// openapiDocType2GoType 文档数据类型转为网关数据类型
|
||||||
//
|
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
|
||||||
//
|
|
||||||
// Date : 21:07 2025/2/26
|
|
||||||
func (hod *handleOpenapiDoc) openapiDocType2GoType(openapiDocType string, formatType string) string {
|
func (hod *handleOpenapiDoc) openapiDocType2GoType(openapiDocType string, formatType string) string {
|
||||||
openapiDocType = strings.ToLower(openapiDocType)
|
openapiDocType = strings.ToLower(openapiDocType)
|
||||||
if formatType == "" {
|
if formatType == "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user