From 4888c7a3dbaa9404bbf3b4117e4f33761916979b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Wed, 7 Jan 2026 11:34:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AF=B7=E6=B1=82schema=20data=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20NIL=20=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- openapi/generate.go | 48 +++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/openapi/generate.go b/openapi/generate.go index c6011b5..a456350 100644 --- a/openapi/generate.go +++ b/openapi/generate.go @@ -169,29 +169,31 @@ func (g *Generate) AddApiDoc(docFlag string, apiMeta define.UriConfig, request a apiOperate, isRead := g.initApiConfig(docFlag, apiMeta) //requestTypeStr := requestType.String() if isRead { - for paramName, paramConfig := range schemaData.Value.Properties { - apiOperate.Parameters = append(apiOperate.Parameters, &openapi3.ParameterRef{ - Extensions: nil, - Origin: nil, - Ref: "", - Value: &openapi3.Parameter{ - Extensions: nil, - Origin: nil, - Name: paramName, - In: strings.ToLower(consts.RequestDataLocationQuery.String()), - Description: paramConfig.Value.Description, - Style: "", - Explode: nil, - AllowEmptyValue: paramConfig.Value.AllowEmptyValue, - AllowReserved: false, - Deprecated: false, - Required: op_array.ArrayType(paramConfig.Value.Required).Has(paramName) >= 0, - Schema: paramConfig, - Example: nil, - Examples: nil, - Content: nil, - }, - }) + if nil != schemaData { + for paramName, paramConfig := range schemaData.Value.Properties { + apiOperate.Parameters = append(apiOperate.Parameters, &openapi3.ParameterRef{ + Extensions: nil, + Origin: nil, + Ref: "", + Value: &openapi3.Parameter{ + Extensions: nil, + Origin: nil, + Name: paramName, + In: strings.ToLower(consts.RequestDataLocationQuery.String()), + Description: paramConfig.Value.Description, + Style: "", + Explode: nil, + AllowEmptyValue: paramConfig.Value.AllowEmptyValue, + AllowReserved: false, + Deprecated: false, + Required: op_array.ArrayType(paramConfig.Value.Required).Has(paramName) >= 0, + Schema: paramConfig, + Example: nil, + Examples: nil, + Content: nil, + }, + }) + } } } else { apiOperate.RequestBody = &openapi3.RequestBodyRef{