Parcourir la source

fix: int64生成一个也是integer

dcsunny il y a 1 an
Parent
commit
52d6c989d7
4 fichiers modifiés avec 22 ajouts et 42 suppressions
  1. 2 2
      go.mod
  2. 2 6
      go.sum
  3. 1 1
      handler.go
  4. 17 33
      service.go

+ 2 - 2
go.mod

@@ -3,11 +3,10 @@ module git.ikuban.com/server/swagger-api
 go 1.22.1
 
 require (
-	git.ikuban.com/server/gnostic v0.0.0-20240530063106-f9a918014ef8
+	git.ikuban.com/server/gnostic v0.0.0-20240530064730-8f512a3e0f7b
 	github.com/go-kratos/kratos/v2 v2.7.3
 	github.com/gorilla/mux v1.8.1
 	github.com/xmkuban/utils v0.0.12
-	google.golang.org/grpc v1.64.0
 	google.golang.org/protobuf v1.34.1
 )
 
@@ -24,5 +23,6 @@ require (
 	golang.org/x/text v0.14.0 // indirect
 	google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
 	google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
+	google.golang.org/grpc v1.64.0 // indirect
 	gopkg.in/yaml.v3 v3.0.1 // indirect
 )

+ 2 - 6
go.sum

@@ -593,10 +593,8 @@ cloud.google.com/go/workflows v1.9.0/go.mod h1:ZGkj1aFIOd9c8Gerkjjq7OW7I5+l6cSvT
 cloud.google.com/go/workflows v1.10.0/go.mod h1:fZ8LmRmZQWacon9UCX1r/g/DfAXx5VcPALq2CxzdePw=
 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
 gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zumjgTw83q2ge/PI+yyw8=
-git.ikuban.com/server/gnostic v0.0.0-20240530012907-80ffc2e6ca93 h1:mE3Gde3W5Y/HfH03rAo/EotgEG4jJqZQoR6q/DwS2zA=
-git.ikuban.com/server/gnostic v0.0.0-20240530012907-80ffc2e6ca93/go.mod h1:s13LfeZt1veCF59BOzdUwRDGrj1hiFv8O6i+orAx5H4=
-git.ikuban.com/server/gnostic v0.0.0-20240530063106-f9a918014ef8 h1:b5/wMeCuOuxAcQeh3fJLlT20vTRfdG9R1/3sUpOiVFY=
-git.ikuban.com/server/gnostic v0.0.0-20240530063106-f9a918014ef8/go.mod h1:s13LfeZt1veCF59BOzdUwRDGrj1hiFv8O6i+orAx5H4=
+git.ikuban.com/server/gnostic v0.0.0-20240530064730-8f512a3e0f7b h1:A6zrB/uKU6r0BhdYkYdYPPiVqnL/dujwh8jtmg6wJVQ=
+git.ikuban.com/server/gnostic v0.0.0-20240530064730-8f512a3e0f7b/go.mod h1:s13LfeZt1veCF59BOzdUwRDGrj1hiFv8O6i+orAx5H4=
 git.sr.ht/~sbinet/gg v0.3.1/go.mod h1:KGYtlADtqsqANL9ueOFkWymvzUvLMQllU5Ixo+8v3pc=
 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
@@ -833,8 +831,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
 github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
-github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ=
-github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc=
 github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
 github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
 github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=

+ 1 - 1
handler.go

@@ -16,7 +16,7 @@ var staticFS embed.FS
 
 func NewHandler(servicesList []string) http.Handler {
 
-	service := New(nil)
+	service := New()
 	r := mux.NewRouter()
 
 	r.HandleFunc("/q/services", func(w http.ResponseWriter, r *http.Request) {

+ 17 - 33
service.go

@@ -3,12 +3,10 @@ package swagger_api
 import (
 	"context"
 	"fmt"
-	//"git.ikuban.com/server/swagger-api/protoc-gen-openapiv2/generator"
-	generatorJson "git.ikuban.com/server/gnostic/protoc-gen-jsonschema/generator"
+
 	"git.ikuban.com/server/gnostic/protoc-gen-openapi/generator"
 	"github.com/go-kratos/kratos/v2/api/metadata"
 	"github.com/xmkuban/utils/utils"
-	"google.golang.org/grpc"
 	"google.golang.org/protobuf/compiler/protogen"
 	"google.golang.org/protobuf/types/descriptorpb"
 	"google.golang.org/protobuf/types/pluginpb"
@@ -16,18 +14,14 @@ import (
 
 // Service is service
 type Service struct {
-	ser     *metadata.Server
-	outType string
+	ser *metadata.Server
 }
 
 // New service
-func New(srv *grpc.Server, outType string) *Service {
-	if outType == "" {
-		outType = "yaml"
-	}
+func New() *Service {
+
 	return &Service{
-		ser:     metadata.NewServer(srv),
-		outType: outType,
+		ser: metadata.NewServer(nil),
 	}
 }
 
@@ -75,28 +69,18 @@ func (s *Service) GetServiceOpenAPI(ctx context.Context, in *metadata.GetService
 	plugin.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL)
 
 	var content []byte
-	if s.outType == "yaml" {
-		gen := generator.NewOpenAPIv3Generator(plugin, generator.Configuration{
-			Version:         utils.ToPointString("1.0"),
-			Title:           utils.ToPointString(""),
-			Description:     utils.ToPointString(""),
-			Naming:          utils.ToPointString("json"),
-			FQSchemaNaming:  utils.ToPointBool(true),
-			EnumType:        utils.ToPointString("integer"),
-			CircularDepth:   utils.ToPointInt(2),
-			DefaultResponse: utils.ToPointBool(false),
-			OutputMode:      utils.ToPointString("merged"),
-		}, plugin.Files)
-		content, err = gen.RunV2()
-	} else {
-		gen := generatorJson.NewJSONSchemaGenerator(plugin, generatorJson.Configuration{
-			BaseURL:  utils.ToPointString(""),
-			Version:  utils.ToPointString("1.0"),
-			Naming:   utils.ToPointString("json"),
-			EnumType: utils.ToPointString("integer"),
-		})
-		content, err = gen.RunV2()
-	}
+	gen := generator.NewOpenAPIv3Generator(plugin, generator.Configuration{
+		Version:         utils.ToPointString("1.0"),
+		Title:           utils.ToPointString(""),
+		Description:     utils.ToPointString(""),
+		Naming:          utils.ToPointString("json"),
+		FQSchemaNaming:  utils.ToPointBool(true),
+		EnumType:        utils.ToPointString("integer"),
+		CircularDepth:   utils.ToPointInt(2),
+		DefaultResponse: utils.ToPointBool(false),
+		OutputMode:      utils.ToPointString("merged"),
+	}, plugin.Files)
+	content, err = gen.RunV2()
 
 	if err != nil {
 		return "", err