From 1ef5dad7a9cfcf573ce4e2e13c9e6f727b4fbe1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Mon, 19 Aug 2024 16:32:51 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=96=B0=E8=A7=84=E5=88=92=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=8E=A5=E5=8F=A3=E7=9A=84=E6=96=B9=E6=B3=95=E7=AD=BE?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- define/generate.go | 26 ++++++++++++++++++++++++++ generate.go | 11 +++-------- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/define/generate.go b/define/generate.go index daf934e..aa97da3 100644 --- a/define/generate.go +++ b/define/generate.go @@ -20,3 +20,29 @@ type UriBaseConfig struct { Summary string `json:"summary"` // 接口摘要描述 Description string `json:"description"` // 接口详细描述 } + +// ParamConfig 参数配置 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 16:23 2024/8/19 +type ParamConfig struct { + Location string `json:"location"` // 参数位置 + Path string `json:"path"` // 参数路径 + Type string `json:"type"` // 参数类型 + Title string `json:"title"` // 参数标题 + Description string `json:"description"` // 参数描述 +} + +// ResultConfig 返回值配置 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 16:23 2024/8/19 +type ResultConfig struct { + Location string `json:"location"` // 返回值位置 + Path string `json:"path"` // 返回值路径 + Type string `json:"type"` // 返回值类型 + Title string `json:"title"` // 返回值标题 + Description string `json:"description"` // 返回值描述 +} diff --git a/generate.go b/generate.go index ab31b09..5b60bea 100644 --- a/generate.go +++ b/generate.go @@ -10,7 +10,6 @@ package api_doc import ( "git.zhangdeman.cn/gateway/api-doc/define" "git.zhangdeman.cn/zhangdeman/consts" - "reflect" "strings" ) @@ -156,14 +155,10 @@ type PathItemOperationConfig struct { // Description: "这是一份示例基础配置", // } // -// parameterPtr : 请求表单结构体实例, 必须为指针, 作用 -> 基于反射生成参数文档 +// paramList : 参数列表 // -// resultPtr : 返回值结构体实例, 必须为指针, 作用 -> 基于反射生成返回值文档 -func (g *Generate) AddApi(baseCfg *define.UriBaseConfig, parameterPtr any, resultPtr any) error { - paramType := reflect.TypeOf(parameterPtr) - for idx := 0; idx < paramType.NumField(); idx++ { +// resultList : 返回值列表 +func (g *Generate) AddApi(baseCfg *define.UriBaseConfig, paramList []*define.ParamConfig, resultList []*define.ResultConfig) error { - } - resultType := reflect.TypeOf(resultPtr) return nil }