Skip to content

fix: 兼容二维数组生成, 更新 go.mod #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions example/user.api
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,10 @@ service user-api {
)
@handler searchUser
get /user/search (UserSearchReq) returns (UserInfoReply)

@doc(
summary: 所有用户
)
@handler searchUserAll
get /user/searchAll (UserSearchReq) returns ([]UserInfoReq)
}
16 changes: 15 additions & 1 deletion example/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@
"in": "path",
"required": true,
"type": "string"
},
{
"name": "sign",
"in": "header",
"required": true,
"type": "string"
}
],
"tags": [
Expand Down Expand Up @@ -230,7 +236,15 @@
},
"UserInfoReq": {
"type": "object",
"title": "UserInfoReq"
"properties": {
"sign": {
"type": "string"
}
},
"title": "UserInfoReq",
"required": [
"sign"
]
},
"UserSearchReq": {
"type": "object",
Expand Down
4 changes: 3 additions & 1 deletion generate/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ func renderServiceRoutes(service spec.Service, groups []spec.Group, paths swagge

respSchema.Type = "array"
respSchema.Items = &swaggerItemsObject{Ref: fmt.Sprintf("#/definitions/%s", refTypeName)}
} else if route.ResponseType.Name() == "string" {
respSchema.Type = "string"
} else {
respSchema.Ref = fmt.Sprintf("#/definitions/%s", route.ResponseType.Name())
}
Expand All @@ -235,7 +237,7 @@ func renderServiceRoutes(service spec.Service, groups []spec.Group, paths swagge
}

if value := group.GetAnnotation("swtags"); len(value) > 0 {
tags = value
tags = strings.Trim(value, "\"")
}

operationObject := &swaggerOperationObject{
Expand Down
87 changes: 82 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,88 @@
module github.com/zeromicro/goctl-swagger

go 1.16
go 1.24.0

require (
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/urfave/cli/v2 v2.11.0
github.com/zeromicro/go-zero v1.6.5
github.com/zeromicro/go-zero/tools/goctl v1.6.5
golang.org/x/oauth2 v0.17.0
github.com/urfave/cli/v2 v2.27.6
github.com/zeromicro/go-zero v1.8.3
github.com/zeromicro/go-zero/tools/goctl v1.8.3
golang.org/x/oauth2 v0.29.0
)

require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210521184019-c5ad59b459ec // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect
github.com/emicklei/proto v1.14.1 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/fatih/structtag v1.2.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.21.1 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/spec v0.21.1-0.20250328170532-a3928469592e // indirect
github.com/go-openapi/swag v0.23.1 // indirect
github.com/go-sql-driver/mysql v1.9.0 // indirect
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
github.com/golang/glog v1.2.1 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gookit/color v1.5.4 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgx/v5 v5.7.4 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
github.com/mailru/easyjson v0.9.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/openzipkin/zipkin-go v0.4.3 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/prometheus/client_golang v1.21.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.62.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/cobra v1.9.1 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1 // indirect
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
github.com/zeromicro/antlr v0.0.1 // indirect
github.com/zeromicro/ddl-parser v1.0.5 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/zipkin v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/sdk v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/automaxprocs v1.6.0 // indirect
golang.org/x/crypto v0.33.0 // indirect
golang.org/x/net v0.35.0 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/text v0.22.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240711142825-46eb208f015d // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.36.5 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading