Skip to content

Commit

Permalink
1. 新增生成ts工具make:ts
Browse files Browse the repository at this point in the history
2. 生成js工具增加http_from、info_tags选项
3. 修复生成js的部分字段类型缺失的问题
4. 修复生成swagger时的required在部分场景不正确问题
  • Loading branch information
zodial committed Dec 14, 2023
1 parent d495e50 commit f12e0aa
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions console/commands/js_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 + "?"
}
Expand All @@ -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)
}
}
Expand Down

0 comments on commit f12e0aa

Please sign in to comment.