From f12e0aad58a5cdb6b60e4e3b0406d7f348037cb3 Mon Sep 17 00:00:00 2001 From: Zodial Date: Thu, 14 Dec 2023 16:02:01 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E6=96=B0=E5=A2=9E=E7=94=9F=E6=88=90ts?= =?UTF-8?q?=E5=B7=A5=E5=85=B7make:ts=202.=20=E7=94=9F=E6=88=90js=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E5=A2=9E=E5=8A=A0http=5Ffrom=E3=80=81info=5Ftags?= =?UTF-8?q?=E9=80=89=E9=A1=B9=203.=20=E4=BF=AE=E5=A4=8D=E7=94=9F=E6=88=90j?= =?UTF-8?q?s=E7=9A=84=E9=83=A8=E5=88=86=E5=AD=97=E6=AE=B5=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E7=BC=BA=E5=A4=B1=E7=9A=84=E9=97=AE=E9=A2=98=204.=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=9F=E6=88=90swagger=E6=97=B6=E7=9A=84re?= =?UTF-8?q?quired=E5=9C=A8=E9=83=A8=E5=88=86=E5=9C=BA=E6=99=AF=E4=B8=8D?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- console/commands/js_request.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/console/commands/js_request.go b/console/commands/js_request.go index f04d261..6081d51 100644 --- a/console/commands/js_request.go +++ b/console/commands/js_request.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "github.com/ctfang/command" + "github.com/go-home-admin/home/bootstrap/utils" "github.com/go-home-admin/toolset/console/commands/openapi" "github.com/go-home-admin/toolset/parser" "io" @@ -328,6 +329,9 @@ func getObjectStrFromRef(ref string, swagger openapi.Spec) string { return "number" } for key, schema := range swagger.Definitions[def].Properties { + if key == "list" { + utils.Dump(key) + } if !isResponse && !parser.InArrString(key, swagger.Definitions[def].Required) { key = key + "?" } @@ -345,18 +349,14 @@ func getJsType(schema *openapi.Schema, swagger openapi.Spec, ref string) string case "integer", "Number": t = "number" case "array": - t = "[]" if schema.Items != nil { - if ref == schema.Items.Ref { - t = "{}" + t - } else { - t = getJsType(schema.Items, swagger, schema.Items.Ref) + t - } + t = getJsType(schema.Items, swagger, ref) } + t += "[]" case "object", "": if ref == schema.Ref { t = "{}" - } else { + } else if schema.Ref != "" { t = getObjectStrFromRef(schema.Ref, swagger) } }